Skip to content

Commit

Permalink
Cleanup test fixtures naming
Browse files Browse the repository at this point in the history
  • Loading branch information
rosstuck committed Dec 10, 2014
1 parent 7af8368 commit 11e3683
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 30 deletions.
18 changes: 9 additions & 9 deletions tests/Tactician/Tests/CommandBus/ExecutingCommandBusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use Tactician\CommandBus\ExecutingCommandBus;
use Tactician\Handler\MethodNameInflector\MethodNameInflector;
use Tactician\Handler\Locator\HandlerLocator;
use Tactician\Tests\Fixtures\Command\TaskCompletedCommand;
use Tactician\Tests\Fixtures\Command\CompleteTaskCommand;
use Tactician\Tests\Fixtures\Handler\DynamicMethodsHandler;
use Tactician\Tests\Fixtures\Handler\TaskCompletedHandler;
use Tactician\Tests\Fixtures\Handler\ConcreteMethodsHandler;
use stdClass;
use Mockery;

Expand Down Expand Up @@ -41,19 +41,19 @@ protected function setUp()

public function testHandlerIsExecuted()
{
$command = new TaskCompletedCommand();
$command = new CompleteTaskCommand();

$handler = Mockery::mock(TaskCompletedHandler::class);
$handler = Mockery::mock(ConcreteMethodsHandler::class);
$handler
->shouldReceive('handleTaskCompletedCommand')
->shouldReceive('handleCompleteTaskCommand')
->with($command)
->once()
->andReturn('a-return-value');

$this->methodNameInflector
->shouldReceive('inflect')
->withArgs([$command, $handler])
->andReturn('handleTaskCompletedCommand');
->andReturn('handleCompleteTaskCommand');

$this->handlerLocator
->shouldReceive('getHandlerForCommand')
Expand All @@ -68,7 +68,7 @@ public function testHandlerIsExecuted()
*/
public function testMissingMethodOnHandlerObjectIsDetected()
{
$command = new TaskCompletedCommand();
$command = new CompleteTaskCommand();

$this->methodNameInflector
->shouldReceive('inflect')
Expand All @@ -83,7 +83,7 @@ public function testMissingMethodOnHandlerObjectIsDetected()

public function testDynamicMethodNamesAreSupported()
{
$command = new TaskCompletedCommand();
$command = new CompleteTaskCommand();
$handler = new DynamicMethodsHandler();

$this->methodNameInflector
Expand All @@ -104,7 +104,7 @@ public function testDynamicMethodNamesAreSupported()

public function testClosuresCanBeInvoked()
{
$command = new TaskCompletedCommand();
$command = new CompleteTaskCommand();
$closureWasExecuted = false;
$handler = function () use (&$closureWasExecuted) {
$closureWasExecuted = true;
Expand Down
10 changes: 5 additions & 5 deletions tests/Tactician/Tests/CommandBus/QueueingCommandBusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Mockery;
use Tactician\CommandBus\CommandBus;
use Tactician\CommandBus\QueueingCommandBus;
use Tactician\Tests\Fixtures\Command\TaskAddedCommand;
use Tactician\Tests\Fixtures\Command\TaskCompletedCommand;
use Tactician\Tests\Fixtures\Command\AddTaskCommand;
use Tactician\Tests\Fixtures\Command\CompleteTaskCommand;

class QueueingCommandBusTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -31,7 +31,7 @@ public function setup()

public function testInnerCommandBusReceivesCommand()
{
$command = new TaskAddedCommand();
$command = new AddTaskCommand();

$this->innerCommandBus
->shouldReceive('execute')
Expand All @@ -47,8 +47,8 @@ public function testInnerCommandBusReceivesCommand()

public function testCommandsAreQueuedIfAnotherCommandIsBeingExecuted()
{
$firstCommand = new TaskAddedCommand();
$secondCommand = new TaskCompletedCommand();
$firstCommand = new AddTaskCommand();
$secondCommand = new CompleteTaskCommand();
$secondCommandDispatched = false;

$this->innerCommandBus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

namespace Tactician\Tests\Fixtures\Command;

class TaskAddedCommand
class AddTaskCommand
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

namespace Tactician\Tests\Fixtures\Command;

class TaskCompletedCommand
class CompleteTaskCommand
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
namespace Tactician\Tests\Fixtures\Handler;

/**
*
* Sample handler that has all commands specified as individual methods, rather
* than using magic methods like __call or __invoke.
*/
class TaskCompletedHandler
class ConcreteMethodsHandler
{
public function handleTaskCompletedCommand($command)
{
Expand Down
8 changes: 4 additions & 4 deletions tests/Tactician/Tests/Handler/Locator/InMemoryLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Tactician\Tests\Handler\Locator;

use Tactician\Handler\Locator\InMemoryLocator;
use Tactician\Tests\Fixtures\Command\TaskCompletedCommand;
use Tactician\Tests\Fixtures\Command\CompleteTaskCommand;

class InMemoryLocatorTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -21,11 +21,11 @@ public function testHandlerIsReturnedForSpecificClass()
{
$handler = new \stdClass();

$this->inMemoryLocator->addHandler($handler, TaskCompletedCommand::class);
$this->inMemoryLocator->addHandler($handler, CompleteTaskCommand::class);

$this->assertSame(
$handler,
$this->inMemoryLocator->getHandlerForCommand(new TaskCompletedCommand())
$this->inMemoryLocator->getHandlerForCommand(new CompleteTaskCommand())
);
}

Expand All @@ -34,6 +34,6 @@ public function testHandlerIsReturnedForSpecificClass()
*/
public function testHandlerMissing()
{
$this->inMemoryLocator->getHandlerForCommand(new TaskCompletedCommand());
$this->inMemoryLocator->getHandlerForCommand(new CompleteTaskCommand());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
namespace Tactician\Tests\Handler\MethodNameInflector;

use Tactician\Handler\MethodNameInflector\HandleClassNameInflector;
use Tactician\Tests\Fixtures\Command\TaskCompletedCommand;
use Tactician\Tests\Fixtures\Handler\TaskCompletedHandler;
use Tactician\Tests\Fixtures\Command\CompleteTaskCommand;
use Tactician\Tests\Fixtures\Handler\ConcreteMethodsHandler;
use stdClass;

class HandleClassNameInflectorTest extends \PHPUnit_Framework_TestCase
Expand All @@ -21,7 +21,7 @@ class HandleClassNameInflectorTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->inflector = new HandleClassNameInflector();
$this->handler = new TaskCompletedHandler();
$this->handler = new ConcreteMethodsHandler();
}

public function testHandlesClassesWithoutNamespace()
Expand All @@ -36,10 +36,10 @@ public function testHandlesClassesWithoutNamespace()

public function testHandlesNamespacedClasses()
{
$command = new TaskCompletedCommand();
$command = new CompleteTaskCommand();

$this->assertEquals(
'handleTaskCompletedCommand',
'handleCompleteTaskCommand',
$this->inflector->inflect($command, $this->mockHandler)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
namespace Tactician\Tests\Handler\MethodNameInflector;

use Tactician\Handler\MethodNameInflector\InvokeInflector;
use Tactician\Tests\Fixtures\Command\TaskCompletedCommand;
use Tactician\Tests\Fixtures\Handler\TaskCompletedHandler;
use Tactician\Tests\Fixtures\Command\CompleteTaskCommand;
use Tactician\Tests\Fixtures\Handler\ConcreteMethodsHandler;

/**
* Best. Test. Ever.
Expand All @@ -16,7 +16,7 @@ public function testReturnsInvokeMagicMethod()

$this->assertEquals(
'__invoke',
$inflector->inflect(new TaskCompletedCommand(), new TaskCompletedHandler())
$inflector->inflect(new CompleteTaskCommand(), new ConcreteMethodsHandler())
);
}
}

0 comments on commit 11e3683

Please sign in to comment.