CliCommandPathValidatorTest::getInvalidValues()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 0
loc 10
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
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