Passed
Push — task/update-scrutinizer-config ( 4a930c )
by Chris
09:18
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
<?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;
24
        $rules = [
25
            'test' => new ContainsObjectWithAttributeRule('b', 8)
26
        ];
27
        $validator = Validator::make($testObj, $rules);
28
        $this->assertTrue($validator->passes());
29
    }
30
}
31