/** * @Route("/{article}", name="articles_get_single") * @Method({"GET"}) */ public function getSingleAction(Request $request, Article $article) { $this->initializeJsonResponse(); if (!$this->checkValidJsonApi($request)) { return $this->jsonResponse; } $articles = array_map(function ($article) { return array('type' => 'articles', 'id' => $article->getId(), 'attributes' => array('headline' => $article->getHeadline(), 'byline' => $article->getByline(), 'leadParagraph' => $article->getLeadParagraph(), 'body' => $article->getBody())); }, array($article)); $this->jsonResponse->setData(array('data' => $articles[0])); return $this->jsonResponse; }
/** * @expectedException \InvalidArgumentException */ public function testSetAndGetBylineBreaksWithInteger() { // Arrange $article = new Article(); $bylineBefore = 4; // Act $article->setByline($bylineBefore); $bylineAfter = $article->getByline(); // Assert $this->assertEquals($bylineBefore, $bylineAfter); }