EntityExistsValidatorTest::testIsNotValid()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
/**
3
 * @author Stefano Torresi (http://stefanotorresi.it)
4
 * @license See the file LICENSE.txt for copying permission.
5
 * ************************************************
6
 */
7
8
namespace Thorr\Persistence\Test\Validator;
9
10
use PHPUnit_Framework_TestCase as TestCase;
11
use Thorr\Persistence\Validator\EntityExistsValidator;
12
13
class EntityExistsValidatorTest extends TestCase
14
{
15
    public function testIsValid()
16
    {
17
        $finder = function ($value) {
18
            return [ $value ];
19
        };
20
21
        $validator = new EntityExistsValidator([ 'finder' => $finder]);
22
23
        $this->assertTrue($validator->isValid('foo'));
24
    }
25
26
    public function testIsNotValid()
27
    {
28
        $finder = function () {
29
            return [];
30
        };
31
32
        $validator = new EntityExistsValidator([ 'finder' => $finder]);
33
34
        $this->assertFalse($validator->isValid('foo'));
35
36
        $this->assertArrayHasKey(EntityExistsValidator::ERROR_ENTITY_NOT_EXISTS, $validator->getMessages());
37
    }
38
}
39