コード例 #1
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testSetAndGetHeadlineBreaksWithInteger()
 {
     // Arrange
     $article = new Article();
     $headlineBefore = 4;
     // Act
     $article->setHeadline($headlineBefore);
     $headlineAfter = $article->getHeadline();
     // Assert
     $this->assertEquals($headlineBefore, $headlineAfter);
 }
コード例 #2
0
 /**
  * @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;
 }