mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-30 11:40:13 +02:00
39 lines
768 B
PHP
39 lines
768 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Tests\Visitor\Tests;
|
|
|
|
use DesignPatterns\Behavioral\Visitor;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class VisitorTest extends TestCase
|
|
{
|
|
/**
|
|
* @var Visitor\RoleVisitor
|
|
*/
|
|
private $visitor;
|
|
|
|
protected function setUp()
|
|
{
|
|
$this->visitor = new Visitor\RoleVisitor();
|
|
}
|
|
|
|
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]);
|
|
}
|
|
}
|