public function testMultilingual() { // change simple content $dataDe = ['title' => 'Testname-DE', 'blog' => 'German', 'url' => '/news/test']; // update content $structureDe = $this->mapper->save($dataDe, 'default', 'sulu_io', 'de', 1); $dataEn = ['title' => 'Testname-EN', 'blog' => 'English', 'url' => '/news/test']; $structureEn = $this->mapper->save($dataEn, 'default', 'sulu_io', 'en', 1, true, $structureDe->getUuid())->toArray(); $structureDe = $this->mapper->load($structureDe->getUuid(), 'sulu_io', 'de'); // check data $this->assertNotEquals($structureDe->getPropertyValue('title'), $structureEn['title']); $this->assertEquals($structureDe->getPropertyValue('blog'), $structureEn['blog']); $this->assertEquals($dataEn['title'], $structureEn['title']); $this->assertEquals($dataEn['blog'], $structureEn['blog']); $this->assertEquals($dataDe['title'], $structureDe->getPropertyValue('title')); // En has overritten german content $this->assertEquals($dataEn['blog'], $structureDe->getPropertyValue('blog')); $root = $this->session->getRootNode(); $route = $root->getNode('cmf/sulu_io/routes/de/news/test'); /** @var NodeInterface $content */ $content = $route->getPropertyValue('sulu:content'); $this->assertEquals($dataDe['title'], $content->getPropertyValue($this->languageNamespace . ':de-title')); $this->assertNotEquals($dataDe['blog'], $content->getPropertyValue('blog')); $this->assertEquals($dataEn['title'], $content->getPropertyValue($this->languageNamespace . ':en-title')); $this->assertEquals($dataEn['blog'], $content->getPropertyValue('blog')); $this->assertFalse($content->hasProperty($this->languageNamespace . ':de-blog')); $this->assertFalse($content->hasProperty($this->languageNamespace . ':en-blog')); $this->assertFalse($content->hasProperty('title')); }
public function testPropertyLengthAttribute() { $rootNode = $this->session->getRootNode(); $node = $rootNode->addNode('testLengthAttribute'); $data = array('simpleString' => array('simplestring', PropertyType::STRING, 12), 'mbString' => array('stringMultibitę¼¢', PropertyType::STRING, 17), 'long' => array(42, PropertyType::LONG, 2), 'double' => array(3.1415, PropertyType::DOUBLE, 6), 'decimal' => array(3.141592, PropertyType::DECIMAL, 8), 'date' => array(new \DateTime('now'), PropertyType::DATE, 29), 'booleanTrue' => array(true, PropertyType::BOOLEAN, 1), 'booleanFalse' => array(false, PropertyType::BOOLEAN, 0), 'name' => array('nt:unstructured', PropertyType::NAME, 15), 'uri' => array('https://google.com', PropertyType::URI, 18), 'path' => array('/root/testLengthAttribute', PropertyType::PATH, 25)); foreach ($data as $propertyName => $propertyInfo) { $node->setProperty($propertyName, $propertyInfo[0], $propertyInfo[1]); } $this->session->save(); $statement = $this->getConnection()->executeQuery('SELECT props FROM phpcr_nodes WHERE path = ?', array('/testLengthAttribute')); $xml = $statement->fetchColumn(); $this->assertNotEquals(false, $xml); $doc = new \DOMDocument('1.0', 'utf-8'); $doc->loadXML($xml); $xpath = new \DOMXPath($doc); foreach ($data as $propertyName => $propertyInfo) { $propertyElement = $xpath->query(sprintf('sv:property[@sv:name="%s"]', $propertyName)); $this->assertEquals(1, $propertyElement->length); $values = $xpath->query('sv:value', $propertyElement->item(0)); /** @var $value \DOMElement */ foreach ($values as $index => $value) { $lengthAttribute = $value->attributes->getNamedItem('length'); if (null === $lengthAttribute) { $this->fail(sprintf('Value %d for property "%s" is expected to have an attribute "length"', $index, $propertyName)); } $this->assertEquals($propertyInfo[2], $lengthAttribute->nodeValue); } } }