Failed Conditions
Branch ignore-unknown-keywords (efa676)
by Stéphane
02:58
created

testNormalizeThrowsIfNotANumber()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the JVal package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace JVal\Constraint;
11
12
use JVal\Context;
13
use JVal\Testing\ConstraintTestCase;
14
15
class MultipleOfConstraintTest extends ConstraintTestCase
16
{
17
    public function testNormalizeThrowsIfNotANumber()
18
    {
19
        $this->expectConstraintException('InvalidTypeException', '/multipleOf');
20
        $schema = $this->loadSchema('invalid/multiple-of-not-number');
21
        $this->getConstraint()->normalize($schema, new Context(), $this->mockWalker());
22
    }
23
24
    /**
25
     * @dataProvider nonPositiveMultipleOfProvider
26
     *
27
     * @param string $schemaName
28
     */
29
    public function testNormalizeThrowsOnNonPositiveNumber($schemaName)
30
    {
31
        $this->expectConstraintException('NotStrictlyPositiveException', '/multipleOf');
32
        $schema = $this->loadSchema($schemaName);
33
        $this->getConstraint()->normalize($schema, new Context(), $this->mockWalker());
34
    }
35
36
    public function nonPositiveMultipleOfProvider()
37
    {
38
        return [
39
            ['invalid/multiple-of-not-positive-1'],
40
            ['invalid/multiple-of-not-positive-2'],
41
        ];
42
    }
43
44
    protected function getConstraint()
45
    {
46
        return new MultipleOfConstraint();
47
    }
48
49
    protected function getCaseFileNames()
50
    {
51
        return ['multipleOf'];
52
    }
53
}
54