Пример #1
0
 /**
  * @dataProvider provideCollectionTypes
  */
 public function testSynchronizeCollection($type)
 {
     if ($type === 'ref') {
         $this->article->addTag($u1 = new ArticleTag('Russland'));
         $this->article->addTag($u2 = new ArticleTag('Demonstration'));
         $this->article->addTag($d1 = new ArticleTag('Protest'));
         $this->article->addTag($d2 = new ArticleTag('Wahl'));
         $n1 = new ArticleTag('Präsidentenwahl');
     }
     if ($type === 'id') {
         $this->article->addTag($u1 = new ArticleTag('Russland'));
         $u1->setId(1);
         $this->article->addTag($u2 = new ArticleTag('Demonstration'));
         $u2->setId(2);
         $this->article->addTag($d1 = new ArticleTag('Protest'));
         $d1->setId(4);
         $this->article->addTag($d2 = new ArticleTag('Wahl'));
         $d2->setId(5);
         $n1 = new ArticleTag('Präsidentenwahl');
         $n1->setId(10);
     }
     if ($type === 'mixed') {
         $this->article->addTag($u1 = new ArticleTag('Russland'));
         $u1->setId(1);
         $this->article->addTag($u2 = new ArticleTag('Demonstration'));
         $this->article->addTag($d1 = new ArticleTag('Protest'));
         $d1->setId(4);
         $this->article->addTag($d2 = new ArticleTag('Wahl'));
         $d2->setId(5);
         $n1 = new ArticleTag('Präsidentenwahl');
     }
     $this->assertEntityCollectionSame(new ArrayCollection(array($u1, $u2, $d1, $d2)), $this->article->getTags(), 'tags-initial');
     $formTags = array($u1, $u2, $n1);
     $this->processor->synchronizeCollection('tags', $formTags);
     //print $this->processor->log;
     $this->assertEntityCollectionEquals(new ArrayCollection(array($n1)), $this->emm->getPersisted(), 'persisted');
     $this->assertEntityCollectionEquals(new ArrayCollection(array($n1, $u1, $u2)), $this->article->getTags(), 'tags-processed');
 }