/** * Test * * @return void */ public function testGetValueModel() { $this->assertInstanceOf('Gc\\Property\\Value\\Model', $this->object->getValueModel()); }
/** * Test * * @return void */ public function testExport() { $this->createUser(); $this->createContent(); $result = $this->object->export($this->what); $this->assertInternalType('string', $result); $dom = new SimpleXMLElement($result); //Test documents $this->assertContains('<documents>', $result); $xpath = $dom->xpath('/gotcms/documents/document[@id="' . $this->document->getId() . '"]/name'); $this->assertEquals($this->document->getName(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/documents/document[@id="' . $this->document->getId() . '"]/url_key'); $this->assertEquals('', (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/documents/document[@id="' . $this->document->getId() . '"]/document_type_id'); $this->assertEquals($this->document->getDocumentTypeId(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/documents/document[@id="' . $this->document->getId() . '"]/layout_id'); $this->assertEquals($this->document->getLayoutId(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/documents/document[@id="' . $this->document->getId() . '"]/view_id'); $this->assertEquals($this->document->getViewId(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/documents/document[@id="' . $this->document->getId() . '"]/parent_id'); $this->assertEquals($this->document->getParentId(), (string) $xpath[0]); //Test documents properties $this->assertContains('<properties>', $result); $xpath = $dom->xpath('/gotcms/documents/document[@id="' . $this->document->getId() . '"]/properties/property_value[@id="' . $this->property->getValueModel()->getId() . '"]/document_id'); $this->assertEquals($this->document->getId(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/documents/document[@id="' . $this->document->getId() . '"]/properties/property_value[@id="' . $this->property->getValueModel()->getId() . '"]/property_id'); $this->assertEquals($this->property->getId(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/documents/document[@id="' . $this->document->getId() . '"]/properties/property_value[@id="' . $this->property->getValueModel()->getId() . '"]/value'); $this->assertEquals(base64_encode($this->property->getValueModel()->getValue()), (string) $xpath[0]); //Test document types $this->assertContains('<document_types>', $result); $xpath = $dom->xpath('/gotcms/document_types/document_type[@id="' . $this->documentType->getId() . '"]/name'); $this->assertEquals($this->documentType->getName(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/document_types/document_type[@id="' . $this->documentType->getId() . '"]/description'); $this->assertEquals($this->documentType->getDescription(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/document_types/document_type[@id="' . $this->documentType->getId() . '"]/icon_id'); $this->assertEquals($this->documentType->getIconId(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/document_types/document_type[@id="' . $this->documentType->getId() . '"]/default_view_id'); $this->assertEquals($this->documentType->getDefaultViewId(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/document_types/document_type[@id="' . $this->documentType->getId() . '"]/user_id'); $this->assertEquals($this->documentType->getUserId(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/document_types/document_type[@id="' . $this->documentType->getId() . '"]/tabs/tab[@id="' . $this->tabModel->getId() . '"]/name'); $this->assertEquals($this->tabModel->getName(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/document_types/document_type[@id="' . $this->documentType->getId() . '"]/tabs/tab[@id="' . $this->tabModel->getId() . '"]/description'); $this->assertEquals($this->tabModel->getDescription(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/document_types/document_type[@id="' . $this->documentType->getId() . '"]/tabs/tab[@id="' . $this->tabModel->getId() . '"]/properties/property[@id="' . $this->property->getId() . '"]/name'); $this->assertEquals($this->property->getName(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/document_types/document_type[@id="' . $this->documentType->getId() . '"]/tabs/tab[@id="' . $this->tabModel->getId() . '"]/properties/property[@id="' . $this->property->getId() . '"]/identifier'); $this->assertEquals($this->property->getIdentifier(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/document_types/document_type[@id="' . $this->documentType->getId() . '"]/tabs/tab[@id="' . $this->tabModel->getId() . '"]/properties/property[@id="' . $this->property->getId() . '"]/description'); $this->assertEquals($this->property->getDescription(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/document_types/document_type[@id="' . $this->documentType->getId() . '"]/tabs/tab[@id="' . $this->tabModel->getId() . '"]/properties/property[@id="' . $this->property->getId() . '"]/required'); $this->assertEquals((int) $this->property->getRequired(), (int) $xpath[0]); $this->assertEquals((int) $this->property->getRequired(), (int) $xpath[0]); $xpath = $dom->xpath('/gotcms/document_types/document_type[@id="' . $this->documentType->getId() . '"]/tabs/tab[@id="' . $this->tabModel->getId() . '"]/properties/property[@id="' . $this->property->getId() . '"]/datatype_id'); $this->assertEquals($this->datatype->getId(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/document_types/document_type[@id="' . $this->documentType->getId() . '"]/dependencies/id[text()="' . $this->documentType->getId() . '"]'); $this->assertEquals($this->documentType->getId(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/document_types/document_type[@id="' . $this->documentType->getId() . '"]/available_views/id[text()="' . $this->view->getId() . '"]'); $this->assertEquals($this->view->getId(), (string) $xpath[0]); //Test views $this->assertContains('<views>', $result); $xpath = $dom->xpath('/gotcms/views/view[@id="' . $this->view->getId() . '"]/name'); $this->assertEquals($this->view->getName(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/views/view[@id="' . $this->view->getId() . '"]/identifier'); $this->assertEquals($this->view->getIdentifier(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/views/view[@id="' . $this->view->getId() . '"]/description'); $this->assertEquals($this->view->getDescription(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/views/view[@id="' . $this->view->getId() . '"]/content'); $this->assertEquals($this->view->getContent(), (string) $xpath[0]); //Test layouts $this->assertContains('<views>', $result); $xpath = $dom->xpath('/gotcms/layouts/layout[@id="' . $this->layout->getId() . '"]/name'); $this->assertEquals($this->layout->getName(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/layouts/layout[@id="' . $this->layout->getId() . '"]/identifier'); $this->assertEquals($this->layout->getIdentifier(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/layouts/layout[@id="' . $this->layout->getId() . '"]/description'); $this->assertEquals($this->layout->getDescription(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/layouts/layout[@id="' . $this->layout->getId() . '"]/content'); $this->assertEquals($this->layout->getContent(), (string) $xpath[0]); //Test scripts $this->assertContains('<views>', $result); $xpath = $dom->xpath('/gotcms/scripts/script[@id="' . $this->script->getId() . '"]/name'); $this->assertEquals($this->script->getName(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/scripts/script[@id="' . $this->script->getId() . '"]/identifier'); $this->assertEquals($this->script->getIdentifier(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/scripts/script[@id="' . $this->script->getId() . '"]/description'); $this->assertEquals($this->script->getDescription(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/scripts/script[@id="' . $this->script->getId() . '"]/content'); $this->assertEquals($this->script->getContent(), (string) $xpath[0]); //Test datatype $this->assertContains('<views>', $result); $xpath = $dom->xpath('/gotcms/datatypes/datatype[@id="' . $this->datatype->getId() . '"]/name'); $this->assertEquals($this->datatype->getName(), (string) $xpath[0]); $xpath = $dom->xpath('/gotcms/datatypes/datatype[@id="' . $this->datatype->getId() . '"]/prevalue_value'); $this->assertEquals($this->datatype->getPrevalueValue(), (string) unserialize($xpath[0])); $xpath = $dom->xpath('/gotcms/datatypes/datatype[@id="' . $this->datatype->getId() . '"]/model'); $this->assertEquals($this->datatype->getModel(), (string) $xpath[0]); $this->removeContent(); $this->removeUser(); }