Beispiel #1
0
 /**
  * test if a correct status is well known
  */
 public function testIfIncorrectStatusIsNotKnown()
 {
     $article = new Article();
     $this->assertEquals(false, $article->statusIsKnown('___123'));
     $this->assertEquals(false, $article->statusIsKnown(''));
     $this->assertEquals(false, $article->statusIsKnown('ONLINE'));
     $this->assertEquals(false, $article->statusIsKnown('OFFLINE'));
     $this->assertEquals(false, $article->statusIsKnown('Online'));
     $this->assertEquals(false, $article->statusIsKnown('Offline'));
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $this->manager = $manager;
     foreach ($this->getData() as $article) {
         $articleObject = new Article();
         $articleObject->setTitle($article['title'])->setDescription($article['description'])->setAuthor($article['author']);
         if (isset($article['status'])) {
             $articleObject->setStatus($article['status']);
         }
         $tagToAdd = [];
         if (isset($article['tags'])) {
             foreach ($article['tags'] as $label) {
                 $tag = new Tag();
                 $tag->setLabel($label);
                 $this->manager->persist($tag);
                 $tagToAdd[] = ['label' => $tag->getLabel(), 'slug' => $tag->getSlug()];
             }
             $articleObject->setTags($tagToAdd);
         }
         $manager->persist($articleObject);
         $manager->flush();
     }
 }
Beispiel #3
0
 /**
  * @param Article $entity
  */
 public function postArticle(Article $entity)
 {
     $guzzle = new GuzzleClient(['base_uri' => $this->endpoint]);
     $result = $guzzle->request('POST', '/articles', ['json' => ['article' => ['title' => $entity->getTitle(), 'leading' => $entity->getLeading(), 'createdBy' => $entity->getCreatedBy(), 'body' => $entity->getBody()]]]);
 }