GenericAttributeTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 30
rs 10
c 1
b 1
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getValidator() 0 6 1
A itIsRequired() 0 5 1
A itIsNotNull() 0 5 1
1
<?php
2
/**
3
 * Author: Nil Portugués Calderó <[email protected]>
4
 * Date: 9/20/14
5
 * Time: 1:49 PM
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Tests\NilPortugues\Validator\Attribute;
12
13
use NilPortugues\Validator\Validator;
14
15
/**
16
 * Class GenericAttributeTest
17
 * @package Tests\NilPortugues\Validator\Attribute
18
 */
19
class GenericAttributeTest extends \PHPUnit_Framework_TestCase
20
{
21
    /**
22
     * @return \NilPortugues\Validator\Attribute\String\StringAttribute
23
     */
24
    protected function getValidator()
25
    {
26
        $validator = Validator::create();
27
28
        return $validator->isString('propertyName');
29
    }
30
31
    /**
32
     * @test
33
     */
34
    public function itIsRequired()
35
    {
36
        $this->assertTrue($this->getValidator()->isRequired()->validate('a'));
37
        $this->assertFalse($this->getValidator()->isRequired()->validate(''));
38
    }
39
40
    /**
41
     * @test
42
     */
43
    public function itIsNotNull()
44
    {
45
        $this->assertTrue($this->getValidator()->isNotNull()->validate('a'));
46
        $this->assertFalse($this->getValidator()->isNotNull()->validate(''));
47
    }
48
}
49