public function testWriteMetadata()
 {
     $parentClasses = array(self::CLASS_TEST_2, self::CLASS_TEST_3);
     $this->node->expects($this->at(0))->method('setProperty')->with('phpcr:class', self::CLASS_TEST_1, PropertyType::STRING);
     $this->dm->expects($this->once())->method('getClassMetadata')->with(self::CLASS_TEST_1)->will($this->returnValue($this->metadata));
     $this->metadata->expects($this->once())->method('getParentClasses')->will($this->returnValue($parentClasses));
     // Assert that we set the correct parent classes
     $this->node->expects($this->at(1))->method('setProperty')->with('phpcr:classparents', $parentClasses, PropertyType::STRING);
     $this->mapper->writeMetadata($this->dm, $this->node, self::CLASS_TEST_1);
 }
 public function testRootEdgeCase()
 {
     $this->buildMocks('/');
     $this->managerRegistry->expects($this->any())->method('getManagerForClass')->with(get_class($this->object))->will($this->returnValue($this->documentManager));
     $this->documentManager->expects($this->any())->method('getNodeForDocument')->with($this->object)->willReturn($this->node);
     $this->node->expects($this->any())->method('getDepth')->will($this->returnValue(4));
     $urlInformation = new UrlInformation();
     $this->guesser->guessValues($urlInformation, $this->object, 'default');
     $this->assertEquals(3, $urlInformation->getDepth());
 }
Example #3
0
 public function testWriteMultipleDifferentTypes()
 {
     $this->prepareMultipleBlockProperty();
     $this->node = $this->getMock('\\Jackalope\\Node', ['setProperty'], [], '', false);
     $result = [];
     $this->node->expects($this->any())->method('setProperty')->will($this->returnCallback(function () use(&$result) {
         $args = func_get_args();
         $result[$args[0]] = $args[1];
     }));
     $data = [['type' => 'type1', 'title' => 'Test-Title-1', 'article' => ['Test-Article-1-1', 'Test-Article-1-2'], 'sub-block' => [['type' => 'subType1', 'title' => 'Test-Title-Sub-1', 'article' => 'Test-Article-Sub-1']]], ['type' => 'type2', 'name' => 'Test-Name-2']];
     $this->blockProperty->setValue($data);
     $this->blockContentType->write($this->node, new TranslatedProperty($this->blockProperty, 'de', 'i18n'), 1, 'default', 'de', '');
     // check repository node
     $this->assertEquals(['i18n:de-block1-length' => 2, 'i18n:de-block1-type#0' => $data[0]['type'], 'i18n:de-block1-title#0' => $data[0]['title'], 'i18n:de-block1-article#0' => $data[0]['article'], 'i18n:de-block1-sub-block#0-length' => 1, 'i18n:de-block1-sub-block#0-type#0' => $data[0]['sub-block'][0]['type'], 'i18n:de-block1-sub-block#0-title#0' => $data[0]['sub-block'][0]['title'], 'i18n:de-block1-sub-block#0-article#0' => $data[0]['sub-block'][0]['article'], 'i18n:de-block1-type#1' => $data[1]['type'], 'i18n:de-block1-name#1' => $data[1]['name']], $result);
     // check resulted structure
     $this->assertEquals($data, $this->blockProperty->getValue());
 }