public function testOutputObject() { $this->_question->setId(1); $poll = new \Pollex\Entity\Poll(); $poll->setId(1337); $this->_question->setPoll($poll); $type = new \Pollex\Entity\Type(); $type->setId(2); $type->setName('free'); $this->_question->setType($type); $this->_question->setTitle('fooo'); $this->_question->setValue('lorem ipsum'); $expected = new \stdClass(); $expected->id = 1; $expected->poll = 1337; $expected->url = '/polls/1337/questions/1'; $expectedType = new \stdClass(); $expectedType->id = 2; $expectedType->name = "free"; $expectedType->url = "/types/2"; $expectedType->created = $type->getCreated()->format(\Pollex\Entity\Base::DATE_FORMAT); $expectedType->updated = $type->getUpdated()->format(\Pollex\Entity\Base::DATE_FORMAT); $expected->type = $expectedType; $expected->created = $this->_question->getCreated()->format(\Pollex\Entity\Base::DATE_FORMAT); $expected->updated = $this->_question->getUpdated()->format(\Pollex\Entity\Base::DATE_FORMAT); $expected->title = "fooo"; $expected->value = 'lorem ipsum'; $expectedAnswers = new \stdClass(); $expectedAnswers->url = '/polls/1337/questions/1/answers'; $expectedAnswers->data = array(); $expected->answers = $expectedAnswers; $this->assertEquals($expected, $this->_question->getOutputObject()); }
public function testGetOutputObject() { $this->_answer->setId(1); $poll = new \Pollex\Entity\Poll(); $poll->setId(2); $this->_answer->setPoll($poll); $question = new \Pollex\Entity\Poll\Question(); $question->setId(3); $question->setPoll($poll); $this->_answer->setQuestion($question); $type = new \Pollex\Entity\Type(); $type->setId(4); $type->setName('fooo'); $this->_answer->setType($type); $this->_answer->setValue('barbar'); $expected = new \stdClass(); $expected->id = 1; $expected->poll = 2; $expected->question = 3; $expected->created = $this->_answer->getCreated()->format(\Pollex\Entity\Base::DATE_FORMAT); $expected->updated = $this->_answer->getUpdated()->format(\Pollex\Entity\Base::DATE_FORMAT); $expected->url = '/polls/2/questions/3/answers/1'; $expected->type = new \stdClass(); $expected->type->id = 4; $expected->type->name = 'fooo'; $expected->type->url = '/types/4'; $expected->type->created = $type->getCreated()->format(\Pollex\Entity\Base::DATE_FORMAT); $expected->type->updated = $type->getUpdated()->format(\Pollex\Entity\Base::DATE_FORMAT); $expected->value = "barbar"; $this->assertEquals($expected, $this->_answer->getOutputObject()); }