Completed
Push — master ( 52970f...c6d773 )
by Tristan
24:57 queued 10:40
created

ContainsObjectWithAttributeRuleTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 13
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testPasses() 0 17 2
1
<?php
2
3
namespace Tests\Unit\ValidationRules;
4
5
use Tests\TestCase;
6
use Illuminate\Foundation\Testing\RefreshDatabase;
7
use App\Services\Validation\Rules\ContainsObjectWithAttributeRule;
8
use Illuminate\Support\Facades\Validator;
9
10
class ContainsObjectWithAttributeRuleTest extends TestCase
11
{
12
    public function testPasses()
13
    {
14
        $array = [];
15
        for ($i = 0; $i < 5; $i++) {
16
            $object = [
17
                'a' => $i,
18
                'b' => $i*2,
19
                'c' => $i*3,
20
            ];
21
            $array[] = $object;
22
        }
23
        $testObj['test'] = $array;
0 ignored issues
show
Comprehensibility Best Practice introduced by
$testObj was never initialized. Although not strictly required by PHP, it is generally a good practice to add $testObj = array(); before regardless.
Loading history...
24
        $rules = [
25
            'test' => new ContainsObjectWithAttributeRule('b', 8)
26
        ];
27
        $validator = Validator::make($testObj, $rules);
28
        $this->assertTrue($validator->passes());
29
    }
30
}
31