Skip to content

Commit

Permalink
Request instantiation moved out of Interactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Kupreev committed Jun 18, 2014
1 parent 0d29b02 commit 03068ec
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
5 changes: 1 addition & 4 deletions app/interactor/Task/Creation.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(
$this->session = $session;
}

public function execute(Request\Task\Creation $request)
public function execute(Request\Task\Creation $request, Response\Task\Creation $response)
{
$userId = $this->session->getLoggedInUserId();
$this->taskRepo->create(
Expand All @@ -52,9 +52,6 @@ public function execute(Request\Task\Creation $request)
$request->getNotes()
);

$response = new Response\Task\Creation;
$response->setStatusOk();

return $response;
}
}
3 changes: 2 additions & 1 deletion app/response/Task/Creation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Response of Task Creation Interactor
*
*/
class Creation extends Service\Response {
class Creation extends Service\Response
{

}
3 changes: 2 additions & 1 deletion app/service/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* Base Response class
*
*/
abstract class Response {
abstract class Response
{

const OK = 200;
const ERROR_VALIDATION = 400;
Expand Down
8 changes: 6 additions & 2 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use app\interactor as Interactor;
use app\service as Service;
use app\request as Request;
use app\response as Response;

/**
* Features context.
Expand Down Expand Up @@ -94,9 +95,12 @@ public function iCreateATaskWithTheFollowingInformation(TableNode $table)
}

$request = new Request\Task\Creation($data);
$response = new Response\Task\Creation;

$taskCreator = new Interactor\Task\Creation($this->taskRepo, $this->userRepo, $this->sessionService);
$this->response = $taskCreator->execute($request);
$taskCreator->execute($request, $response);

$this->response = $response;
}

/**
Expand All @@ -112,7 +116,7 @@ public function taskShouldBeCreated()
*/
public function taskShouldNotBeCreated()
{
Test::assertFalse($this->response);
Test::assertFalse($this->response->isStatusOk());
}

/**
Expand Down

0 comments on commit 03068ec

Please sign in to comment.