finished writing StackApiControllerTest.php

Signed-off-by: Ryan Fletcher <ryan.fletcher@codepassion.ca>
This commit is contained in:
Ryan Fletcher
2018-07-16 10:53:31 -04:00
committed by Julius Härtl
parent f2268c7f58
commit f1169b9c7e

View File

@@ -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);
}
}