mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-29 19:20:18 +02:00
39 lines
809 B
PHP
39 lines
809 B
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace DesignPatterns\Tests\Visitor\Tests;
|
|
|
|
use DesignPatterns\Behavioral\Visitor;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class VisitorTest extends TestCase
|
|
{
|
|
/**
|
|
* @var Visitor\RecordingVisitor
|
|
*/
|
|
private $visitor;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->visitor = new Visitor\RecordingVisitor();
|
|
}
|
|
|
|
public function provideRoles()
|
|
{
|
|
return [
|
|
[new Visitor\User('Dominik')],
|
|
[new Visitor\Group('Administrators')],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideRoles
|
|
*
|
|
* @param Visitor\Role $role
|
|
*/
|
|
public function testVisitSomeRole(Visitor\Role $role)
|
|
{
|
|
$role->accept($this->visitor);
|
|
$this->assertSame($role, $this->visitor->getVisited()[0]);
|
|
}
|
|
}
|