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
@@ 563-590 (lines=28) @@
560
     * @expectedException              Sensorario\Resources\Exceptions\UnexpectedValueException
561
     * @expectedExceptionMessageRegExp #Value `.*` is not allowed for key `.*`. Allowed values are:#
562
     */
563
    public function testAllowedValues()
564
    {
565
        $configurator = new Configurator(
566
            'foo',
567
            new Container([
568
                'resources' => [
569
                    'foo' => [
570
                        'constraints' => [
571
                            'allowed' => [ 'user_type' ],
572
                            'allowedValues' => [
573
                                'user_type' => [
574
                                    4, 
575
                                    7,
576
                                ],
577
                            ],
578
                        ],
579
                    ],
580
                ],
581
            ])
582
        );
583
584
        $properties = [ 'user_type' => 3 ];
585
586
        Resource::box(
587
            $properties,
588
            $configurator
589
        );
590
    }
591
592
    public function testRewriteRulesWithCondition()
593
    {
@@ 649-676 (lines=28) @@
646
     * @expectedException              Sensorario\Resources\Exceptions\OutOfRangeException
647
     * @expectedExceptionMessageRegExp #Value `.*` is out of range: `.*`.#
648
     */
649
    public function testAcceptRangeOfValues()
650
    {
651
        $configurator = new Configurator(
652
            'foo',
653
            new Container([
654
                'resources' => [
655
                    'foo' => [
656
                        'constraints' => [
657
                            'allowedRanges' => [
658
                                'age' => [
659
                                    'more_than' => 3,
660
                                    'less_than' => 42,
661
                                ],
662
                            ],
663
                            'allowed' => [
664
                                'age'
665
                            ],
666
                        ],
667
                    ],
668
                ],
669
            ])
670
        );
671
672
        Resource::box(
673
            [ 'age' => 2 ],
674
            $configurator
675
        );
676
    }
677
678
    public function testAllResourcesInheritGlobalAllowingConfiguration()
679
    {

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 test()
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
    {