Code Duplication    Length = 24-28 lines in 4 locations

tests/Sensorario/Resources/ResourceTest.php 3 locations

@@ 59-82 (lines=24) @@
56
     * @expectedException              Sensorario\Resources\Exceptions\NotAllowedKeyException
57
     * @expectedExceptionMessageRegExp #Key `.*::.*` is not allowed#
58
     */
59
    public function testNotAllowedFieldThroghRuntimeException()
60
    {
61
        $configurator = new Configurator(
62
            'empty_resource',
63
            new Container([
64
                'resources' => [
65
                    'empty_resource' => [
66
                        'constraints' => [
67
                            'allowedValues' => [
68
                                'name',
69
                                'surname',
70
                            ],
71
                        ],
72
                    ],
73
                ],
74
            ])
75
        );
76
77
        $resource = Resource::box([
78
            'name' => 'Simone',
79
            'surname' => 'Gentili',
80
            'not allowed' => 'foo',
81
        ], $configurator);
82
    }
83
84
    /**
85
     * @expectedException              Sensorario\Resources\Exceptions\PropertyException
@@ 525-552 (lines=28) @@
522
     * @expectedException              Sensorario\Resources\Exceptions\UnexpectedValueException
523
     * @expectedExceptionMessageRegExp #Value `.*` is not allowed for key `.*`. Allowed values are:#
524
     */
525
    public function testAllowedValues()
526
    {
527
        $configurator = new Configurator(
528
            'foo',
529
            new Container([
530
                'resources' => [
531
                    'foo' => [
532
                        'constraints' => [
533
                            'allowed' => [ 'user_type' ],
534
                            'allowedValues' => [
535
                                'user_type' => [
536
                                    4, 
537
                                    7,
538
                                ],
539
                            ],
540
                        ],
541
                    ],
542
                ],
543
            ])
544
        );
545
546
        $properties = [ 'user_type' => 3 ];
547
548
        Resource::box(
549
            $properties,
550
            $configurator
551
        );
552
    }
553
554
    public function testRewriteRulesWithCondition()
555
    {
@@ 611-638 (lines=28) @@
608
     * @expectedException              Sensorario\Resources\Exceptions\OutOfRangeException
609
     * @expectedExceptionMessageRegExp #Value `.*` is out of range: `.*`.#
610
     */
611
    public function testAcceptRangeOfValues()
612
    {
613
        $configurator = new Configurator(
614
            'foo',
615
            new Container([
616
                'resources' => [
617
                    'foo' => [
618
                        'constraints' => [
619
                            'allowedRanges' => [
620
                                'age' => [
621
                                    'more_than' => 3,
622
                                    'less_than' => 42,
623
                                ],
624
                            ],
625
                            'allowed' => [
626
                                'age'
627
                            ],
628
                        ],
629
                    ],
630
                ],
631
            ])
632
        );
633
634
        Resource::box(
635
            [ 'age' => 2 ],
636
            $configurator
637
        );
638
    }
639
640
    public function testAllResourcesInheritGlobalAllowingConfiguration()
641
    {

tests/Sensorario/Resources/RulerTest.php 1 location

@@ 26-51 (lines=26) @@
23
     * @expectedException \Sensorario\Resources\Exceptions\InvalidCustomValidatorException
24
     * @expectedExceptionMessage Oops! `custom-validator` custom validator is not available. Only email is.
25
     */
26
    public function testPropertyCannotContainWrongCustomValidato()
27
    {
28
        $configurator = new Configurator(
29
            'foo',
30
            new Container([
31
                'resources' => [
32
                    'foo' => [
33
                        'constraints' => [
34
                            'allowed' => [
35
                                'property_name',
36
                            ],
37
                            'rules' => [
38
                                'property_name' => [
39
                                    'custom-validator' => 'foo',
40
                                ]
41
                            ]
42
                        ],
43
                    ],
44
                ]
45
            ])
46
        );
47
48
        Resource::box([
49
            'property_name' => '42',
50
        ], $configurator);
51
    }
52
53
    public function setUp()
54
    {