CliCommandPathValidatorTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 4
lcom 1
cbo 5
dl 0
loc 47
c 2
b 1
f 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A createValidator() 0 4 1
A testValidCommand() 0 6 1
A getInvalidValues() 0 10 1
A testInvalidValues() 0 10 1
1
<?php
2
3
namespace Tests\FOA\CronBundle\Validator\Constraints;
4
5
use FOA\CronBundle\Validator\Constraints\CliCommandPath;
6
use FOA\CronBundle\Validator\Constraints\CliCommandPathValidator;
7
use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
8
9
/**
10
 * @author JM Leroux <[email protected]>
11
 */
12
class CliCommandPathValidatorTest extends AbstractConstraintValidatorTest
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    protected function createValidator()
18
    {
19
        return new CliCommandPathValidator('/home/akeneo/pim/app');
20
    }
21
22
    public function testValidCommand()
23
    {
24
        $constraint = new CliCommandPath();
25
        $this->validator->validate('php /home/akeneo/pim/app/console debug:container', $constraint);
26
        $this->assertNoViolation();
27
    }
28
29
    /**
30
     * @return array
31
     */
32
    public function getInvalidValues()
33
    {
34
        return [
35
            ['php /home/akeneo/pim/app/hack.php'],
36
            ['php /usr/bin/console'],
37
            ['/home/akeneo/pim/app/console'],
38
            ['php /home/akeneo/pim/app/console_hacked'],
39
            ['app/console'],
40
        ];
41
    }
42
43
    /**
44
     * @dataProvider getInvalidValues
45
     *
46
     * @param string $value
47
     */
48
    public function testInvalidValues($value)
49
    {
50
        $constraint = new CliCommandPath();
51
52
        $this->validator->validate($value, $constraint);
53
54
        $this->buildViolation($constraint->message)
55
            ->setParameter('%string%', $value)
56
            ->assertRaised();
57
    }
58
}
59