Completed
Pull Request — develop (#14)
by jean-marie
02:23
created

CliCommandPathValidatorTest::testValidCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
namespace Tests\FOA\CronBundle\Validator\Constraints;
3
4
use FOA\CronBundle\Manager\Cron;
5
use FOA\CronBundle\Validator\Constraints\CliCommandPath;
6
use FOA\CronBundle\Validator\Constraints\CliCommandPathValidator;
7
use InvalidArgumentException;
8
use PHPUnit\Framework\TestCase;
9
use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
10
11
class CliCommandPathValidatorTest extends AbstractConstraintValidatorTest
12
{
13
    protected function createValidator()
14
    {
15
        return new CliCommandPathValidator('/home/akeneo/pim/app');
16
    }
17
18
    public function testValidCommand()
19
    {
20
        $constraint = new CliCommandPath();
21
        $this->validator->validate('php /home/akeneo/pim/app/console debug:container', $constraint);
22
        $this->assertNoViolation();
23
    }
24
25
    /**
26
     * @dataProvider getInvalidValues
27
     */
28
    public function testInvalidValues($value)
29
    {
30
        $constraint = new CliCommandPath();
31
32
        $this->validator->validate($value, $constraint);
33
34
        $this->buildViolation($constraint->message)
35
            ->setParameter('%string%', $value)
36
            ->assertRaised();
37
    }
38
39
    public function getInvalidValues()
40
    {
41
        return [
42
            ['php /home/akeneo/pim/app/hack.php'],
43
            ['php /usr/bin/console'],
44
            ['/home/akeneo/pim/app/console'],
45
            ['php /home/akeneo/pim/app/console_hacked'],
46
            ['app/console'],
47
        ];
48
    }
49
}
50