-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EZEE-2111: Created unit test for mapping prioritized form templates list
- Loading branch information
Andrew Longosz
committed
Jun 22, 2018
1 parent
bdd6f65
commit b18fb8b
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
src/bundle/Tests/DependencyInjection/Configuration/Parser/AdminUiFormsTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace EzSystems\EzPlatformAdminUiBundle\Tests\DependencyInjection\Configuration\Parser; | ||
|
||
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ContextualizerInterface; | ||
use EzSystems\EzPlatformAdminUiBundle\DependencyInjection\Configuration\Parser\AdminUiForms; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Test AdminUiForms SiteAccess-aware Configuration Parser. | ||
*/ | ||
class AdminUiFormsTest extends TestCase | ||
{ | ||
/** | ||
* @var \EzSystems\EzPlatformAdminUiBundle\DependencyInjection\Configuration\Parser\AdminUiForms | ||
*/ | ||
private $parser; | ||
|
||
/** | ||
* @var \PHPUnit\Framework\MockObject\MockObject|\eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ContextualizerInterface | ||
*/ | ||
private $contextualizer; | ||
|
||
public function setUp() | ||
{ | ||
$this->parser = new AdminUiForms(); | ||
$this->contextualizer = $this->createMock(ContextualizerInterface::class); | ||
} | ||
|
||
/** | ||
* Test given Content edit form templates are sorted according to their priority when mapping. | ||
*/ | ||
public function testContentEditFormTemplatesAreMapped() | ||
{ | ||
$scopeSettings = [ | ||
'admin_ui_forms' => [ | ||
'content_edit_form_templates' => [ | ||
['template' => 'my_template-01.html.twig', 'priority' => 1], | ||
['template' => 'my_template-02.html.twig', 'priority' => 0], | ||
['template' => 'my_template-03.html.twig', 'priority' => 2], | ||
], | ||
], | ||
]; | ||
$currentScope = 'admin_group'; | ||
|
||
$expectedTemplatesList = [ | ||
'my_template-03.html.twig', | ||
'my_template-01.html.twig', | ||
'my_template-02.html.twig', | ||
]; | ||
|
||
$this->contextualizer | ||
->expects($this->once()) | ||
->method('setContextualParameter') | ||
->with( | ||
AdminUiForms::FORM_TEMPLATES_PARAM, | ||
$currentScope, | ||
$expectedTemplatesList | ||
); | ||
|
||
$this->parser->mapConfig($scopeSettings, $currentScope, $this->contextualizer); | ||
} | ||
} |