Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Replaced PrepareWorkspaceEvent with WorkspaceEvent #80

Merged
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions src/Deployment/Strategy/RemoteInstallStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Accompli\EventDispatcher\Event\HostEvent;
use Accompli\EventDispatcher\Event\InstallReleaseEvent;
use Accompli\EventDispatcher\Event\PrepareReleaseEvent;
use Accompli\EventDispatcher\Event\PrepareWorkspaceEvent;
use Accompli\EventDispatcher\Event\WorkspaceEvent;
use Exception;

/**
Expand Down Expand Up @@ -37,10 +37,10 @@ public function install($version, $stage = null)
try {
$this->eventDispatcher->dispatch(AccompliEvents::CREATE_CONNECTION, new HostEvent($host));

$prepareWorkspaceEvent = new PrepareWorkspaceEvent($host);
$this->eventDispatcher->dispatch(AccompliEvents::PREPARE_WORKSPACE, $prepareWorkspaceEvent);
$workspaceEvent = new WorkspaceEvent($host);
$this->eventDispatcher->dispatch(AccompliEvents::PREPARE_WORKSPACE, $workspaceEvent);

$workspace = $prepareWorkspaceEvent->getWorkspace();
$workspace = $workspaceEvent->getWorkspace();
if ($workspace instanceof Workspace) {
$prepareReleaseEvent = new PrepareReleaseEvent($workspace, $version);
$this->eventDispatcher->dispatch(AccompliEvents::PREPARE_RELEASE, $prepareReleaseEvent);
Expand Down
40 changes: 0 additions & 40 deletions src/EventDispatcher/Event/PrepareWorkspaceEvent.php

This file was deleted.

19 changes: 9 additions & 10 deletions src/Task/CreateWorkspaceTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
use Accompli\AccompliEvents;
use Accompli\Deployment\Workspace;
use Accompli\EventDispatcher\Event\LogEvent;
use Accompli\EventDispatcher\Event\PrepareWorkspaceEvent;
use Accompli\EventDispatcher\Event\WorkspaceEvent;
use Accompli\EventDispatcher\EventDispatcherInterface;
use Psr\Log\LogLevel;
use RuntimeException;
use Symfony\Component\EventDispatcher\EventDispatcher;

/**
* CreateWorkspaceTask.
Expand Down Expand Up @@ -78,11 +77,11 @@ public function __construct($releasesDirectory = 'releases/', $dataDirectory = '
/**
* Constructs a new Workspace instance and sets the Workspace on the event.
*
* @param PrepareWorkspaceEvent $event
* @param string $eventName
* @param EventDispatcher $eventDispatcher
* @param WorkspaceEvent $event
* @param string $eventName
* @param EventDispatcherInterface $eventDispatcher
*/
public function onPrepareWorkspaceConstructWorkspaceInstance(PrepareWorkspaceEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
public function onPrepareWorkspaceConstructWorkspaceInstance(WorkspaceEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Creating Workspace.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS)));

Expand All @@ -100,13 +99,13 @@ public function onPrepareWorkspaceConstructWorkspaceInstance(PrepareWorkspaceEve
/**
* Creates the workspace directories when not already existing.
*
* @param PrepareWorkspaceEvent $event
* @param string $eventName
* @param EventDispatcher $eventDispatcher
* @param WorkspaceEvent $event
* @param string $eventName
* @param EventDispatcherInterface $eventDispatcher
*
* @throws RuntimeException
*/
public function onPrepareWorkspaceCreateWorkspace(PrepareWorkspaceEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
public function onPrepareWorkspaceCreateWorkspace(WorkspaceEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
$workspace = $event->getWorkspace();
$connection = $this->ensureConnection($workspace->getHost());
Expand Down
16 changes: 8 additions & 8 deletions tests/Deployment/Strategy/RemoteInstallStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Accompli\EventDispatcher\Event\HostEvent;
use Accompli\EventDispatcher\Event\InstallReleaseEvent;
use Accompli\EventDispatcher\Event\PrepareReleaseEvent;
use Accompli\EventDispatcher\Event\PrepareWorkspaceEvent;
use Accompli\EventDispatcher\Event\WorkspaceEvent;
use PHPUnit_Framework_TestCase;
use Symfony\Component\EventDispatcher\Event;

Expand Down Expand Up @@ -84,7 +84,7 @@ public function testInstallDispatchesEventsSuccessfully()
),
array(
$this->equalTo(AccompliEvents::PREPARE_WORKSPACE),
$this->callback(array($this, 'provideDispatchCallbackForPrepareWorkspaceEvent')),
$this->callback(array($this, 'provideDispatchCallbackForWorkspaceEvent')),
),
array(
$this->equalTo(AccompliEvents::PREPARE_RELEASE),
Expand Down Expand Up @@ -139,7 +139,7 @@ public function testInstallDispatchesEventsSuccessfullyForMultipleHosts()
),
array(
$this->equalTo(AccompliEvents::PREPARE_WORKSPACE),
$this->callback(array($this, 'provideDispatchCallbackForPrepareWorkspaceEvent')),
$this->callback(array($this, 'provideDispatchCallbackForWorkspaceEvent')),
),
array(
$this->equalTo(AccompliEvents::PREPARE_RELEASE),
Expand All @@ -165,7 +165,7 @@ public function testInstallDispatchesEventsSuccessfullyForMultipleHosts()
),
array(
$this->equalTo(AccompliEvents::PREPARE_WORKSPACE),
$this->callback(array($this, 'provideDispatchCallbackForPrepareWorkspaceEvent')),
$this->callback(array($this, 'provideDispatchCallbackForWorkspaceEvent')),
),
array(
$this->equalTo(AccompliEvents::PREPARE_RELEASE),
Expand Down Expand Up @@ -225,7 +225,7 @@ public function testInstallDispatchesEventsSuccessfullyUntillAfterPrepareWorkspa
),
array(
$this->equalTo(AccompliEvents::PREPARE_WORKSPACE),
$this->callback(array($this, 'provideDispatchCallbackForPrepareWorkspaceEvent')),
$this->callback(array($this, 'provideDispatchCallbackForWorkspaceEvent')),
),
array(
$this->equalTo(AccompliEvents::PREPARE_RELEASE),
Expand Down Expand Up @@ -282,7 +282,7 @@ public function testInstallDispatchesEventsSuccessfullyUntillAfterPrepareRelease
array(
$this->equalTo(AccompliEvents::PREPARE_WORKSPACE),
$this->callback(function ($event) {
return ($event instanceof PrepareWorkspaceEvent);
return ($event instanceof WorkspaceEvent);
}),
),
array(
Expand All @@ -309,15 +309,15 @@ public function testInstallDispatchesEventsSuccessfullyUntillAfterPrepareRelease
*
* @return bool
*/
public function provideDispatchCallbackForPrepareWorkspaceEvent(Event $event)
public function provideDispatchCallbackForWorkspaceEvent(Event $event)
{
$workspaceMock = $this->getMockBuilder('Accompli\Deployment\Workspace')
->setConstructorArgs(array($event->getHost()))
->getMock();

$event->setWorkspace($workspaceMock);

return ($event instanceof PrepareWorkspaceEvent);
return ($event instanceof WorkspaceEvent);
}

/**
Expand Down
15 changes: 8 additions & 7 deletions tests/Task/CreateWorkspaceTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
namespace Accompli\Test;

use Accompli\AccompliEvents;
use Accompli\EventDispatcher\Event\PrepareWorkspaceEvent;
use Accompli\EventDispatcher\Event\WorkspaceEvent;
use Accompli\Task\CreateWorkspaceTask;
use PHPUnit_Framework_TestCase;
use RuntimeException;

/**
* CreateWorkspaceTaskTest.
Expand Down Expand Up @@ -50,7 +51,7 @@ public function testConstructWithArguments()
}

/**
* Tests if CreateWorkspaceTask::onPrepareWorkspaceConstructWorkspaceInstance constructs a new Workspace instance and sets it on the PrepareWorkspaceEvent.
* Tests if CreateWorkspaceTask::onPrepareWorkspaceConstructWorkspaceInstance constructs a new Workspace instance and sets it on the WorkspaceEvent.
*
* @depends testConstruct
*/
Expand All @@ -63,7 +64,7 @@ public function testOnPrepareWorkspaceConstructWorkspaceInstance()
->disableOriginalConstructor()
->getMock();

$event = new PrepareWorkspaceEvent($hostMock);
$event = new WorkspaceEvent($hostMock);

$task = new CreateWorkspaceTask();
$task->onPrepareWorkspaceConstructWorkspaceInstance($event, AccompliEvents::PREPARE_WORKSPACE, $eventDispatcherMock);
Expand Down Expand Up @@ -98,7 +99,7 @@ public function testOnPrepareWorkspaceCreateWorkspaceThrowsRuntimeExceptionOnIna
$hostMock->expects($this->once())->method('hasConnection')->willReturn(true);
$hostMock->expects($this->once())->method('getConnection')->willReturn($connectionAdapterMock);

$event = new PrepareWorkspaceEvent($hostMock);
$event = new WorkspaceEvent($hostMock);

$task = new CreateWorkspaceTask();
$task->onPrepareWorkspaceConstructWorkspaceInstance($event, AccompliEvents::PREPARE_WORKSPACE, $eventDispatcherMock);
Expand Down Expand Up @@ -133,7 +134,7 @@ public function testOnPrepareWorkspaceCreateWorkspace()
$hostMock->expects($this->once())->method('hasConnection')->willReturn(true);
$hostMock->expects($this->once())->method('getConnection')->willReturn($connectionAdapterMock);

$event = new PrepareWorkspaceEvent($hostMock);
$event = new WorkspaceEvent($hostMock);

$task = new CreateWorkspaceTask();
$task->onPrepareWorkspaceConstructWorkspaceInstance($event, AccompliEvents::PREPARE_WORKSPACE, $eventDispatcherMock);
Expand Down Expand Up @@ -166,7 +167,7 @@ public function testOnPrepareWorkspaceCreateWorkspaceFailure()
$hostMock->expects($this->once())->method('hasConnection')->willReturn(true);
$hostMock->expects($this->once())->method('getConnection')->willReturn($connectionAdapterMock);

$event = new PrepareWorkspaceEvent($hostMock);
$event = new WorkspaceEvent($hostMock);

$task = new CreateWorkspaceTask();
$task->onPrepareWorkspaceConstructWorkspaceInstance($event, AccompliEvents::PREPARE_WORKSPACE, $eventDispatcherMock);
Expand Down Expand Up @@ -194,7 +195,7 @@ public function testOnPrepareWorkspaceCreateWorkspaceExists()
$hostMock->expects($this->once())->method('hasConnection')->willReturn(true);
$hostMock->expects($this->once())->method('getConnection')->willReturn($connectionAdapterMock);

$event = new PrepareWorkspaceEvent($hostMock);
$event = new WorkspaceEvent($hostMock);

$task = new CreateWorkspaceTask();
$task->onPrepareWorkspaceConstructWorkspaceInstance($event, AccompliEvents::PREPARE_WORKSPACE, $eventDispatcherMock);
Expand Down