/** * POST /notes */ public function testCreate() { $created = new Note(); $created->setId(3); $expected = new Note(); $this->service->expects($this->once())->method('create')->with($this->equalTo($this->userId))->will($this->returnValue($created)); $this->service->expects($this->once())->method('update')->with(3, 'hi', $this->userId)->will($this->returnValue($expected)); $response = $this->controller->create('hi'); $this->assertEquals($expected, $response->getData()); $this->assertTrue($response instanceof DataResponse); }
/** * POST /notes */ public function testCreate() { $content = 'yii'; $note = new Note(); $note->setId(4); $this->service->expects($this->once())->method('create')->with($this->equalTo($this->userId))->will($this->returnValue($note)); $this->service->expects($this->once())->method('update')->with($this->equalTo($note->getId()), $this->equalTo($content), $this->equalTo($this->userId))->will($this->returnValue($note)); $response = $this->controller->create($content); $this->assertEquals($note, $response->getData()); $this->assertTrue($response instanceof DataResponse); }