From f1169b9c7eecea82a2bbc9e2b0ad4b7f22182a6e Mon Sep 17 00:00:00 2001 From: Ryan Fletcher Date: Mon, 16 Jul 2018 10:53:31 -0400 Subject: [PATCH] finished writing StackApiControllerTest.php Signed-off-by: Ryan Fletcher --- .../controller/StackApiControllerTest.php | 49 ++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/tests/unit/controller/StackApiControllerTest.php b/tests/unit/controller/StackApiControllerTest.php index 5f844845d..8ec2cc4fa 100644 --- a/tests/unit/controller/StackApiControllerTest.php +++ b/tests/unit/controller/StackApiControllerTest.php @@ -123,5 +123,52 @@ class StackApiControllerTest extends \Test\TestCase { $expected = new DataResponse($stack, HTTP::STATUS_OK); $actual = $this->controller->create($this->exampleStack['title'], $this->exampleStack['order']); $this->assertEquals($expected, $actual); - } + } + + public function testUpdate() { + + $this->request->expects($this->exactly(2)) + ->method('getParam') + ->withConsecutive( + ['stackId'], + ['boardId'] + ) + ->willReturnonConsecutiveCalls($this->exampleStack['id'], $this->exampleBoard['boardId']); + + $stack = new Stack(); + $stack->setId($this->exampleStack['id']); + $stack->setBoardId($this->exampleStack['boardId']); + $stack->setOrder($this->exampleStack['order']); + $stack->setTitle($this->exampleStack['title']); + + $this->stackService->expects($this->once()) + ->method('update') + ->willReturn($stack); + + $expected = new DataResponse($stack, HTTP::STATUS_OK); + $actual = $this->controller->update($this->exampleStack['title'], $this->exampleStack['order']); + $this->assertEquals($expected, $actual); + } + + public function testDelete() { + + $stack = new Stack(); + $stack->setId($this->exampleStack['id']); + $stack->setBoardId($this->exampleStack['boardId']); + $stack->setOrder($this->exampleStack['order']); + $stack->setTitle($this->exampleStack['title']); + + $this->request->expects($this->once()) + ->method('getParam') + ->with('stackId') + ->will($this->returnValue($this->exampleStack['id'])); + + $this->stackService->expects($this->once()) + ->method('delete') + ->willReturn($stack); + + $expected = new DataResponse($stack, HTTP::STATUS_OK); + $actual = $this->controller->delete(); + $this->assertEquals($expected, $actual); + } } \ No newline at end of file