This repository has been archived by the owner on Mar 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Add unit tests for
ConditionItemResolver
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
Tests/Unit/Configuration/Form/Condition/ConditionItemResolverTest.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,44 @@ | ||
<?php | ||
namespace Romm\Formz\Tests\Unit\Configuration\Condition; | ||
|
||
use Romm\ConfigurationObject\Service\Items\MixedTypes\MixedTypesResolver; | ||
use Romm\Formz\Condition\ConditionFactory; | ||
use Romm\Formz\Condition\Items\ConditionItemInterface; | ||
use Romm\Formz\Configuration\Form\Condition\ConditionItemResolver; | ||
use Romm\Formz\Tests\Unit\AbstractUnitTest; | ||
|
||
class ConditionItemResolverTest extends AbstractUnitTest | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function conditionIsFound() | ||
{ | ||
$conditionItem = $this->getMockBuilder(ConditionItemInterface::class) | ||
->getMockForAbstractClass(); | ||
$conditionClass = get_class($conditionItem); | ||
|
||
ConditionFactory::get()->registerCondition('foo', $conditionClass); | ||
|
||
$resolver = new MixedTypesResolver; | ||
$resolver->setData(['type' => 'foo']); | ||
|
||
ConditionItemResolver::getInstanceClassName($resolver); | ||
|
||
$this->assertEquals($conditionClass, $resolver->getObjectType()); | ||
$this->assertFalse($resolver->getResult()->hasErrors()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function conditionIsNotFound() | ||
{ | ||
$resolver = new MixedTypesResolver; | ||
$resolver->setData(['type' => 'nope']); | ||
|
||
ConditionItemResolver::getInstanceClassName($resolver); | ||
|
||
$this->assertTrue($resolver->getResult()->hasErrors()); | ||
} | ||
} |