EntityExistsValidatorTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 26
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testIsValid() 0 10 1
A testIsNotValid() 0 12 1
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