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

MultipleOfConstraintTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 39
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testNormalizeThrowsIfNotANumber() 0 6 1
A testNormalizeThrowsOnNonPositiveNumber() 0 6 1
A nonPositiveMultipleOfProvider() 0 7 1
A getConstraint() 0 4 1
A getCaseFileNames() 0 4 1
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