Skip to content

Commit 2476868

Browse files
added tests for Violations class
1 parent f947211 commit 2476868

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/Unit/Rules/ViolationsTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,39 @@ public function test_to_string(): void
7272

7373
$this->assertEquals($expected, $this->violationStore->toString());
7474
}
75+
76+
public function test_get_iterable(): void
77+
{
78+
$violation = new Violation(
79+
'App\Controller\Shop',
80+
'should have name end with Controller'
81+
);
82+
$this->violationStore->add($violation);
83+
$iterable = $this->violationStore->getIterator();
84+
85+
$this->assertEquals([
86+
$this->violation,
87+
$violation
88+
], \iterator_to_array($iterable));
89+
}
90+
91+
public function test_get_array(): void
92+
{
93+
$violation1 = new Violation(
94+
'App\Controller\Shop',
95+
'should have name end with Controller'
96+
);
97+
$violation2 = new Violation(
98+
'App\Controller\Shop',
99+
'should implement AbstractController'
100+
);
101+
$this->violationStore->add($violation1);
102+
$this->violationStore->add($violation2);
103+
104+
$this->assertEquals([
105+
$this->violation,
106+
$violation1,
107+
$violation2,
108+
], $this->violationStore->toArray());
109+
}
75110
}

0 commit comments

Comments
 (0)