Example #1
0
 public function testCreateEmbedType()
 {
     $article_type = new ArticleType();
     $paragraph_type = new ParagraphType($article_type, $article_type->getAttribute('content_objects'));
     $this->assertEquals(3, $paragraph_type->getAttributes()->getSize());
     $this->assertEquals('Paragraph', $paragraph_type->getName());
 }
 public function testValueChangedEvents()
 {
     $listener = Mockery::mock(ValueChangedListenerInterface::CLASS);
     $listener->shouldReceive('onValueChanged')->with(ValueChangedEvent::CLASS)->twice();
     $article_type = $this->getTypeMock();
     $embed_type = new ParagraphType($article_type, $article_type->getAttribute('content_objects'));
     $embedd_entity = $embed_type->createEntity(['title' => 'Hello world', 'content' => 'Foobar lorem ipsum...']);
     $embed_attribute = new EmbeddedEntityListAttribute(self::ATTR_NAME, $this->getTypeMock(), [EmbeddedEntityListAttribute::OPTION_ENTITY_TYPES => [ParagraphType::CLASS]]);
     $value = $embed_attribute->createValueHolder();
     $value->addValueChangedListener($listener);
     $entity_list = $value->getValue();
     $entity_list->push($embedd_entity);
     $embedd_entity->setValue('title', 'Kthxbye');
     $this->assertInstanceOf(EntityList::CLASS, $entity_list);
     $this->assertEquals(1, $entity_list->getSize());
 }