Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions tests/Unit/Rules/ViolationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,39 @@ public function test_to_string(): void

$this->assertEquals($expected, $this->violationStore->toString());
}

public function test_get_iterable(): void
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose that the type checker already check this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was trying to explicit it well. I would like to be more specific, any suggestions @fain182 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fain182 I changed the assertion with a more proper one, what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much better 👍

{
$violation = new Violation(
'App\Controller\Shop',
'should have name end with Controller'
);
$this->violationStore->add($violation);
$iterable = $this->violationStore->getIterator();

$this->assertEquals([
$this->violation,
$violation,
], iterator_to_array($iterable));
}

public function test_get_array(): void
{
$violation1 = new Violation(
'App\Controller\Shop',
'should have name end with Controller'
);
$violation2 = new Violation(
'App\Controller\Shop',
'should implement AbstractController'
);
$this->violationStore->add($violation1);
$this->violationStore->add($violation2);

$this->assertEquals([
$this->violation,
$violation1,
$violation2,
], $this->violationStore->toArray());
}
}