public function setUp() { parent::setUp(); ezpINIHelper::setINISetting('site.ini', 'SearchSettings', 'AllowEmptySearch', 'enabled'); ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'SiteLanguageList', array('eng-GB')); $this->findINI = eZINI::instance('ezfind.ini'); $this->findINI->loadCache(true); $this->solrSearch = new eZSolr(); $this->object = new ezpObject('folder', 2); $this->object->name = 'foo'; $this->object->publish(); $this->object->addNode(43); // Add a location under Media node $this->solrSearch->addObject($this->object->object); }
/** * Tests that the output process works with objects. * * There should be no crash from casting errors. * @group templateOperators * @group attributeOperator */ public function testDisplayVariableWithObject() { $db = eZDB::instance(); // STEP 1: Add test folder $folder = new ezpObject( "folder", 2 ); $folder->name = __METHOD__; $folder->publish(); $nodeId = $folder->mainNode->node_id; $node = eZContentObjectTreeNode::fetch( $nodeId ); $attrOp = new eZTemplateAttributeOperator(); $outputTxt = ''; $formatterMock = $this->getMock( 'ezpAttributeOperatorFormatterInterface' ); $formatterMock->expects( $this->any() ) ->method( 'line' ) ->will( $this->returnValue( __METHOD__ ) ); try { $attrOp->displayVariable( $node, $formatterMock, true, 2, 0, $outputTxt ); } catch ( PHPUnit_Framework_Error $e ) { self::fail( "eZTemplateAttributeOperator raises an error when working with objects." ); } self::assertNotNull( $outputTxt, "Output text is empty." ); // this is an approxmiate test. The output shoudl contain the name of the object it has been generated correctly. self::assertContains( __METHOD__, $outputTxt, "There is something wrong with the output of the attribute operator. Object name not found." ); }
/** * Regression test for issue #16078 * * @link http://issues.ez.no/16078 */ public function testIssue16078() { $classID = 5; // image class, can remain hardcoded, I guess $baseImagePath = dirname(__FILE__) . '/ezimagefile_regression_issue16078.png'; $parts = pathinfo($baseImagePath); $imagePattern = $parts['dirname'] . DIRECTORY_SEPARATOR . $parts['filename'] . '_%s_%d.' . $parts['extension']; $toDelete = array(); // Create version 1 $imagePath = sprintf($imagePattern, md5(1), 1); copy($baseImagePath, $imagePath); $toDelete[] = $imagePath; $image = new ezpObject('image', 43); $image->name = __FUNCTION__; $image->image = $imagePath; $image->publish(); $image->refresh(); $publishedDataMap = $image->object->dataMap(); $files = eZImageFile::fetchForContentObjectAttribute($publishedDataMap['image']->attribute('id')); $publishedImagePath = $files[0]; // Create a new image file $imagePath = sprintf($imagePattern, md5(2), 2); copy($baseImagePath, $imagePath); $toDelete[] = $imagePath; // Create version 2 in another language, and remove it $languageCode = 'nor-NO'; $version = self::addTranslationDontPublish($image, $languageCode); $version->removeThis(); // Check that the original file still exists $this->assertTrue(file_exists($publishedImagePath), 'The image file from version 1 should still exist when version 2 is removed'); array_map('unlink', $toDelete); $image->purge(); }
/** * Test regression for issue #13952: Workflow cronjob gives fatal error if * node is moved to different location before approval. * * Test Outline * ------------ * 1. Create a folder * 2. Approve folder * 3. Create child of folder * 4. Approve child * 5. Create a new version and re-publish the child * 6. Move child to root * 7. Approve child * 8. Run approval cronjob * * @result: Fatal error: Call to a member function attribute() on a non-object in * /www/trunk/kernel/content/ezcontentoperationcollection.php on line 313 * @expected: No fatal error * @link http://issues.ez.no/13952 */ public function testApprovalFatalErrorWhenMoving() { $anonymousObjectID = eZUser::fetchByName('anonymous')->attribute('contentobject_id'); // STEP 1: Create a folder $folder = new ezpObject("folder", 2, $anonymousObjectID); $folder->name = "Parent folder (needs approval)"; $folder->publish(); // STEP 2: Approve folder $collaborationItem = eZCollaborationItem::fetch(1); $this->approveCollaborationItem($collaborationItem); $this->runWorkflow(); // STEP 3: Create child of folder $child = new ezpObject("folder", $folder->mainNode->node_id, $anonymousObjectID); $child->name = "Child folder (needs approval)"; $child->publish(); // STEP 4: Approve child $collaborationItem = eZCollaborationItem::fetch(2); $this->approveCollaborationItem($collaborationItem); $this->runWorkflow(); // STEP 5: Re-publish child $newVersion = $child->createNewVersion(); ezpObject::publishContentObject($child->object, $newVersion); // STEP 6: Move child to root $child->mainNode->move(2); // STEP 7: Approve child again $collaborationItem = eZCollaborationItem::fetch(3); $this->approveCollaborationItem($collaborationItem); // STEP 8: Run approval cronjob $this->runWorkflow(); }
/** * test fetchChildListByVersionStatus */ public function testFetchChildListByVersionStatus() { //create object $top = new ezpObject('article', 2); $top->name = 'TOP ARTICLE'; $top->publish(); $child = new ezpObject('article', $top->mainNode->node_id); $child->name = 'THIS IS AN ARTICLE'; $child->publish(); $child2 = new ezpObject('article', $top->mainNode->node_id); $child2->name = 'THIS IS AN ARTICLE2'; $child2->publish(); $pendingChild = new ezpObject('article', $top->mainNode->node_id); $pendingChild->name = 'THIS IS A PENDING ARTICLE'; $pendingChild->publish(); $version = $pendingChild->currentVersion(); $version->setAttribute('status', eZContentObjectVersion::STATUS_PENDING); $version->store(); $idList = array($top->mainNode->node_id); $arrayResult = eZNodeAssignment::fetchChildListByVersionStatus($idList, eZContentObjectVersion::STATUS_PENDING, false); $this->assertEquals($pendingChild->id, $arrayResult[0]['contentobject_id']); $arrayResult = eZNodeAssignment::fetchChildListByVersionStatus($idList, eZContentObjectVersion::STATUS_PUBLISHED, true); $this->assertEquals($child->id, $arrayResult[0]->attribute('contentobject_id')); $countResult = eZNodeAssignment::fetchChildCountByVersionStatus($idList, eZContentObjectVersion::STATUS_PENDING); $this->assertEquals(1, $countResult); $countResult = eZNodeAssignment::fetchChildCountByVersionStatus($idList, eZContentObjectVersion::STATUS_PUBLISHED); $this->assertEquals(2, $countResult); }
/** * Unit test for eZSubtreeNotificationRule::fetchUserList() */ public function testFetchUserList() { // Add a notification rule for admin on root $adminUserID = eZUser::fetchByName( 'admin' )->attribute( 'contentobject_id' ); $rule = new eZSubtreeNotificationRule( array( 'user_id' => $adminUserID, 'use_digest' => 0, 'node_id' => 2 ) ); $rule->store(); // Create a content object below node #2 $article = new ezpObject( 'article', 2 ); $article->title = __FUNCTION__; $article->publish(); $articleContentObject = $article->object; $list = eZSubtreeNotificationRule::fetchUserList( array( 2, 43 ), $articleContentObject ); $this->assertInternalType( 'array', $list, "Return value should have been an array" ); $this->assertEquals( 1, count( $list ), "Return value should have one item" ); $this->assertInternalType( 'array', $list[0] ); $this->assertArrayHasKey( 'user_id', $list[0] ); $this->assertArrayHasKey( 'use_digest', $list[0] ); $this->assertArrayHasKey( 'address', $list[0] ); $this->assertEquals( 14, $list[0]['user_id'] ); $this->assertEquals( 0, $list[0]['use_digest'] ); $this->assertEquals( '*****@*****.**', $list[0]['address'] ); }
/** * Regression test for issue #14983 * * @link http://issues.ez.no/14983 **/ public function testIssue14983() { $className = 'eZImageType test class'; $classIdentifier = 'ezimagetype_test_class'; $attributeName = 'Image'; $attributeIdentifier = 'image'; $attributeType = 'ezimage'; $filePath = 'tests/tests/kernel/datatypes/ezimage/ezimagetype_regression_issue14983.png'; $class = new ezpClass($className, $classIdentifier, $className); $classAttribute = $class->add($attributeName, $attributeIdentifier, $attributeType); $class->store(); $object = new ezpObject($classIdentifier, 2); $object->name = __FUNCTION__; $dataMap = $object->object->dataMap(); $fileAttribute = $dataMap[$attributeIdentifier]; $dataType = new eZImageType(); $dataType->fromString($fileAttribute, $filePath); $fileAttribute->store(); $object->publish(); $object->refresh(); $contentObjectAttributeID = $fileAttribute->attribute("id"); $files = eZImageFile::fetchForContentObjectAttribute($contentObjectAttributeID); $file = $files[0]; // Read stored path, move to trash, and read stored path again $this->assertNotEquals($file, null); $oldFile = $file; $object->object->removeThis(); $object->refresh(); $files = eZImageFile::fetchForContentObjectAttribute($contentObjectAttributeID); $file = $files[0]; $this->assertNotEquals($oldFile, $file, 'The stored file should be renamed when trashed'); }
/** * @group issue18249 */ public function testIssue18249() { // setup a class C1 with objectrelationlist and pattern name $classIdentifier = strtolower( __FUNCTION__ ); $class1 = new ezpClass( __FUNCTION__, $classIdentifier, '<test_name><test_relation>' ); $class1->add( 'Test name', 'test_name', 'ezstring' ); $class1->add( 'Test Relation', 'test_relation', 'ezobjectrelationlist' ); $class1->store(); $o1 = new ezpObject( 'article', 2, 14, 1, 'eng-GB' ); $o1->title = 'Test_ENG'; $o1->publish(); $o1->addTranslation( 'xxx-XX', array( 'title' => 'Test_XXX' ) ); $o2 = new ezpObject( $classIdentifier, 2, 14, 1, 'xxx-XX' ); $o2->test_name = 'name_'; $o2->test_relation = array( $o1->attribute( 'id' ) ); $o2->publish(); // test O2's name $this->assertEquals( 'name_Test_XXX', $o2->name ); }
public function testUpdateAndPublishObject() { // create content object first $object = new ezpObject("folder", 2); $object->title = __FUNCTION__ . '::' . __LINE__ . '::' . time(); $object->publish(); $contentObjectID = $object->attribute('id'); if ($object instanceof eZContentObject) { $now = date('Y/m/d H:i:s', time()); $sectionID = 3; $remoteID = md5($now); $attributeList = array('name' => 'name ' . $now, 'short_name' => 'short_name ' . $now, 'short_description' => 'short_description' . $now, 'description' => 'description' . $now, 'show_children' => false); $params = array(); $params['attributes'] = $attributeList; $params['remote_id'] = $remoteID; $params['section_id'] = $sectionID; $result = eZContentFunctions::updateAndPublishObject($object, $params); $this->assertTrue($result); $object = eZContentObject::fetch($contentObjectID); $this->assertEquals($object->attribute('section_id'), $sectionID); $this->assertEquals($object->attribute('remote_id'), $remoteID); $dataMap = $object->dataMap(); $this->assertEquals($attributeList['name'], $dataMap['name']->content()); $this->assertEquals($attributeList['short_name'], $dataMap['short_name']->content()); $this->assertEquals($attributeList['short_description'], $dataMap['short_description']->content()); $this->assertEquals($attributeList['description'], $dataMap['description']->content()); $this->assertEquals($attributeList['show_children'], (bool) $dataMap['show_children']->content()); } }
/** * @param string $name * @return eZContentObject */ protected function createImage($name) { $imageObject = new ezpObject(self::CLASS_IDENTIFIER, 2); $imageObject->name = $name; $imageObject->image = self::IMAGE_FILE_PATH; $imageObject->publish(); return $this->forceFetchContentObject($imageObject->attribute('id')); }
public function setUp() { parent::setUp(); $classIdentifier = "ezimagetype_test_class"; $this->imageClass = new ezpClass("eZImageType test class", $classIdentifier, "eZImageType test class"); $this->imageClass->add("Image", "image", "ezimage"); $this->imageClass->store(); $this->imageObject = new ezpObject($classIdentifier, 2); $this->imageObject->name = __METHOD__; $dataMap = $this->imageObject->object->dataMap(); $this->fileAttribute = $dataMap["image"]; $dataType = new eZImageType(); $dataType->fromString($this->fileAttribute, self::IMAGE_FILE_PATH); $this->fileAttribute->store(); $this->imageObject->publish(); $this->imageObject->refresh(); }
private function createObjectForRelation($title = false) { if (!$title) { $title = uniqid(__METHOD__); } $relatedObject = new ezpObject('article', 2, 14, 1, 'eng-GB'); $relatedObject->title = $title; return $relatedObject->publish(); }
/** * Creates an article in eZ Publish in the folder $folderId, * with title $articleTitle and summary $articleIntro and returns its ID. * * @param int $folderId * @param string $articleName * @param string $articleIntro * @return int The ID of the article created */ public function createEZPArticle($folderId, $articleTitle, $articleIntro) { $object = new ezpObject('article', $folderId); $object->title = $articleTitle; $object->intro = $articleIntro; $object->publish(); $objectId = (int) $object->attribute('id'); return $objectId; }
/** * Test to verify that eznode_assignment entres get removed. * * @link http://issues.ez.no/15478 */ public function testRemoveAssignments() { $db = eZDB::instance(); $testSet = array(); $folder = new ezpObject( "folder", 2 ); $folder->name = __FUNCTION__; $folder->publish(); $testSet[] = $folder; $childOne = new ezpObject( "folder", $folder->mainNode->node_id ); $childOne->name = "ChildOne"; $childOne->publish(); $testSet[] = $childOne; $childTwo = new ezpObject( "folder", $folder->mainNode->node_id ); $childTwo->name = "ChildTwo"; $childTwo->publish(); $testSet[] = $childTwo; $subChildOne = new ezpObject( 'article', $childOne->mainNode->node_id ); $subChildOne->title = "SubChild"; $subChildOne->publish(); $testSet[] = $subChildOne; $subChildTwo = new ezpObject( 'article', $childOne->mainNode->node_id ); $subChildTwo->title = "SubChildOther"; $subChildTwo->publish(); $testSet[] = $subChildTwo; $subChildThree = new ezpObject( 'article', $childOne->mainNode->node_id ); $subChildThree->title = "SubChildThird"; $subChildThree->publish(); $testSet[] = $subChildThree; // Let's add another placement here $newPlacementSubChildOne = $subChildOne->addNode( $childTwo->mainNode->node_id ); $testSet[] = $newPlacementSubChildOne; // $this->debugBasicNodeInfo( $testSet ); $coId = $newPlacementSubChildOne->attribute( 'contentobject_id' ); eZContentOperationCollection::removeAssignment( $childTwo->mainNode->node_id, $childTwo->id, array( $newPlacementSubChildOne ), false ); $checkSql = "SELECT * FROM eznode_assignment WHERE contentobject_id = {$coId}"; $result = $db->arrayQuery( $checkSql ); // After removing one of the assignments, the number of node // assignments for the content object should be only one. $numberOfAssignments = count( $result ); self::assertEquals( 1, $numberOfAssignments, "The number of node assignments are not correct, eznode_assignment table not cleaned up correctly." ); }
/** * Regression test for issue #15155 * * @link http://issues.ez.no/15155 */ public function testIssue15155() { // figure out the max versions for images $contentINI = eZINI::instance('content.ini'); $versionlimit = $contentINI->variable('VersionManagement', 'DefaultVersionHistoryLimit'); $limitList = eZContentClass::classIDByIdentifier($contentINI->variable('VersionManagement', 'VersionHistoryClass')); $classID = 5; // image class, can remain hardcoded, I guess foreach ($limitList as $key => $value) { if ($classID == $key) { $versionlimit = $value; } } if ($versionlimit < 2) { $versionlimit = 2; } $baseImagePath = dirname(__FILE__) . '/ezimagealiashandler_regression_issue15155.png'; $parts = pathinfo($baseImagePath); $imagePattern = $parts['dirname'] . DIRECTORY_SEPARATOR . $parts['filename'] . '_%s_%d.' . $parts['extension']; $toDelete = array(); // Create version 1 $imagePath = sprintf($imagePattern, md5(1), 1); copy($baseImagePath, $imagePath); $toDelete[] = $imagePath; $image = new ezpObject('image', 43); $image->name = __FUNCTION__; $image->image = $imagePath; $image->publish(); $image->refresh(); $contentObjectID = $image->object->attribute('id'); $dataMap = eZContentObject::fetch($contentObjectID)->dataMap(); $originalAliases[1] = $image->image->imageAlias('original'); for ($i = 2; $i <= 20; $i++) { // Create a new image file $imagePath = sprintf($imagePattern, md5($i), $i); copy($baseImagePath, $imagePath); $toDelete[] = $imagePath; $newVersion = $image->createNewVersion(); $dataMap = $newVersion->dataMap(); $dataMap['image']->fromString($imagePath); ezpObject::publishContentObject($image->object, $newVersion); $image->refresh(); $originalAliases[$i] = $image->image->imageAlias('original'); if ($i > $versionlimit) { $removeVersion = $i - $versionlimit; $aliasPath = $originalAliases[$removeVersion]['url']; $this->assertFalse(file_exists($aliasPath), "Alias {$aliasPath} for version {$removeVersion} should have been removed"); } } array_map('unlink', $toDelete); $image->purge(); }
/** * Regression test for issue #15263 * Content object name/url of imported content classes aren't generated correctly * * @url http://issues.ez.no/15263 * * @outline * 1) Expire and force generation of class attribute cache * 2) Load a test package * 3) Install the package * 4) Publish an object of the imported class * 5) The object name / url alias shouldn't be the expected one **/ public function testIssue15263() { $adminUser = eZUser::fetchByName('admin'); $previousUser = eZUser::currentUser(); eZUser::setCurrentlyLoggedInUser($adminUser, $adminUser->attribute('contentobject_id')); // 1) Expire and force generation of class attribute cache $handler = eZExpiryHandler::instance(); $handler->setTimestamp('class-identifier-cache', time() - 1); $handler->store(); eZContentClassAttribute::classAttributeIdentifierByID(1); // 1) Load a test package $packageName = 'ezpackage_regression_testIssue15223.ezpkg'; $packageFilename = dirname(__FILE__) . DIRECTORY_SEPARATOR . $packageName; $packageImportTried = false; while (!$packageImportTried) { $package = eZPackage::import($packageFilename, $packageName); if (!$package instanceof eZPackage) { if ($package === eZPackage::STATUS_ALREADY_EXISTS) { $packageToRemove = eZPackage::fetch($packageName); $packageToRemove->remove(); } else { self::fail("An error occured loading the package '{$packageFilename}'"); } } $packageImportTried = true; } // 2) Install the package $installParameters = array('site_access_map' => array('*' => false), 'top_nodes_map' => array('*' => 2), 'design_map' => array('*' => false), 'restore_dates' => true, 'user_id' => $adminUser->attribute('contentobject_id'), 'non-interactive' => true, 'language_map' => $package->defaultLanguageMap()); $result = $package->install($installParameters); // 3) Publish an object of the imported class $object = new ezpObject('test_issue_15523', 2, $adminUser->attribute('contentobject_id'), 1); $object->myname = __METHOD__; $object->myothername = __METHOD__; $publishedObjectID = $object->publish(); unset($object); // 4) Test data from the publish object $publishedNodeArray = eZContentObjectTreeNode::fetchByContentObjectID($publishedObjectID); if (count($publishedNodeArray) != 1) { $this->fail("An error occured fetching node for object #{$publishedObjectID}"); } $publishedNode = $publishedNodeArray[0]; if (!$publishedNode instanceof eZContentObjectTreeNode) { $this->fail("An error occured fetching node for object #{$publishedObjectID}"); } else { $this->assertEquals("eZPackageRegression::testIssue15263", $publishedNode->attribute('name')); $this->assertEquals("eZPackageRegression-testIssue15263", $publishedNode->attribute('url_alias')); } // Remove the installed package & restore the logged in user $package->remove(); eZUser::setCurrentlyLoggedInUser($previousUser, $previousUser->attribute('contentobject_id')); }
public function createObject(ezpDatatypeTestDataSet $dataSet) { static $counter = 0; $this->object = new ezpObject($this->class->identifier, 2); $this->object->title = "{$this->datatype} test #" . ++$counter; $dataMap = $this->object->dataMap(); $this->attribute = $dataMap[$this->attributeIdentifier]; try { $attribute = $this->attribute->fromString($dataSet->fromString); } catch (PHPUnit_Framework_Error_Notice $e) { self::fail("A notice has been thrown when calling fromString: " . $e->getMessage()); } $this->object->publish(); }
/** * Test scenario for issue #13552: Broken datamap caching when copying * content objects * * This test verifies that the content object attributes are fresh and not * cached versions of the original object. We can achieve this by comparing * the content object attribute ids, and make sure they are not the same. * */ public function testDataMapFreshOnCopyObject() { $folder = new ezpObject("folder", 2); $folder->name = __FUNCTION__; $folder->short_description = "123"; $folder->publish(); $attrObj1 = self::compareObjectAttributeIds($folder->object); $newObject = self::copyObject($folder->object, 2); $attrObjCopy = self::compareObjectAttributeIds($newObject); $res = array_intersect_assoc($attrObj1, $attrObjCopy); // If the intersection of key-valye pairs in the two arrays are empty, // all the attribute ids are different in the two objects, and we have // fresh copy self::assertTrue(empty($res), "The copied object does contain fresh content object attributes"); }
/** * Regression test for issue #14983 * * @link http://issues.ez.no/14983 */ public function testIssue14983() { $className = 'eZBinaryFileType test class'; $classIdentifier = 'ezbinaryfiletype_test_class'; $attributeName = 'File'; $attributeIdentifier = 'file'; $attributeType = 'ezbinaryfile'; $filePath = 'tests/tests/kernel/datatypes/ezbinaryfile/ezbinaryfiletype_regression_issue14983.txt'; $class = new ezpClass( $className, $classIdentifier, $className ); $classAttribute = $class->add( $attributeName, $attributeIdentifier, $attributeType ); $class->store(); $object = new ezpObject( $classIdentifier, 2 ); $object->name = __FUNCTION__; { $dataMap = $object->object->dataMap(); $fileAttribute = $dataMap[$attributeIdentifier]; { $dataType = new eZBinaryFileType(); $dataType->fromString( $fileAttribute, $filePath ); } $fileAttribute->store(); } $object->publish(); $object->refresh(); $contentObjectAttributeID = $fileAttribute->attribute( "id" ); $files = eZBinaryFile::fetch( $contentObjectAttributeID ); foreach ( $files as $file ) { // Read stored path, move to trash, and read stored path again $this->assertNotEquals( $file, null ); $storedFileInfo = $file->storedFileInfo(); $storedFilePath = $storedFileInfo['filepath']; $version = $file->attribute( 'version' ); $object->object->removeThis(); $object->refresh(); $file = eZBinaryFile::fetch( $contentObjectAttributeID, $version ); $storedFileInfo = $file->storedFileInfo(); $storedFilePathAfterTrash = $storedFileInfo['filepath']; $this->assertNotEquals( $storedFilePath, $storedFilePathAfterTrash, 'The stored file should be renamed when trashed' ); } }
/** * Regression test for issue 16400 * @link http://issues.ez.no/16400 * @return unknown_type */ public function testIssue16400() { $className = 'Media test class'; $classIdentifier = 'media_test_class'; $filePath = 'tests/tests/kernel/datatypes/ezmedia/ezmediatype_regression_issue16400.flv'; eZFile::create($filePath); $attributeName = 'Media'; $attributeIdentifier = 'media'; $attributeType = 'ezmedia'; //1. test method fetchByContentObjectID $class = new ezpClass($className, $classIdentifier, $className); $class->add($attributeName, $attributeIdentifier, $attributeType); $attribute = $class->class->fetchAttributeByIdentifier($attributeIdentifier); $attribute->setAttribute('can_translate', 0); $class->store(); $object = new ezpObject($classIdentifier, 2); $dataMap = $object->object->dataMap(); $fileAttribute = $dataMap[$attributeIdentifier]; $dataType = new eZMediaType(); $dataType->fromString($fileAttribute, $filePath); $fileAttribute->store(); $object->publish(); $object->refresh(); //verify fetchByContentObjectID $mediaObject = eZMedia::fetch($fileAttribute->attribute('id'), 1); $medias = eZMedia::fetchByContentObjectID($object->object->attribute('id')); $this->assertEquals($mediaObject->attribute('filename'), $medias[0]->attribute('filename')); $medias = eZMedia::fetchByContentObjectID($object->object->attribute('id'), $fileAttribute->attribute('language_code')); $this->assertEquals($mediaObject->attribute('filename'), $medias[0]->attribute('filename')); //2. test issue // create translation $contentObject = $object->object; $storedFileName = $mediaObject->attribute('filename'); $version = $contentObject->createNewVersionIn('nor-NO', $fileAttribute->attribute('language_code')); $version->setAttribute('status', eZContentObjectVersion::STATUS_INTERNAL_DRAFT); $version->store(); $version->removeThis(); $sys = eZSys::instance(); $dir = $sys->storageDirectory(); //verify the file is deleted $storedFilePath = $dir . '/original/video/' . $storedFileName; $file = eZClusterFileHandler::instance($storedFilePath); $this->assertTrue($file->exists($storedFilePath)); if ($file->exists($storedFilePath)) { unlink($storedFilePath); } }
public function testSendActivationEmail() { $subscriber = ezcomSubscriber::create(); $subscriber->setAttribute('email', '*****@*****.**'); $subscriber->setAttribute('user_id', 10); $subscriber->store(); $contentObject = new ezpObject('article'); $contentObject->publish(); $subscription = ezcomSubscription::create(); $subscription->setAttribute('subscriber_id', $subscriber->attribute('id')); $subscription->setAttribute('subscriber_type', 'ezcomcomment'); $subscription->setAttribute('enabled', 0); $subscription->setAttribute('content_id', '10_2'); $hashString = ezcomUtility::instance()->generateSubscriptionHashString($subscription); $subscription->setAttribute('hash_string', $hashString); $subscription->store(); // $result = ezcomSubscriptionManager::sendActivationEmail( $contentObject, $subscriber, $subscription ); // $this->assertTrue( $result ); }
public function testIssue18249() { // setup a class C1 with objectrelationlist and pattern name $class1 = new ezpClass('TestClass1', 'testclass1', '<test_name><test_relation>'); $class1->add('Test name', 'test_name', 'ezstring'); $class1->add('Test Relation', 'test_relation', 'ezobjectrelationlist'); $class1->store(); // create an object O1 with eng and nor $o1 = new ezpObject('article', false, 14, 1, 'nor-NO'); $o1->title = 'Test_NOR'; $o1->publish(); $o1->addTranslation('nor-NO', array('title' => 'Test_NOR')); // create an object O2 based on C1 with Nor $o2 = new ezpObject('testclass1', false, 14, 1, 'nor-NO'); $o2->test_name = 'name_'; $o2->test_relation = array($o1->attribute('id')); $o2->publish(); // test O2's name $this->assertEquals('name_Test_NOR', $o2->name); }
/** * Tests that the output process works with objects. * * There should be no crash from casting errors. * */ public function testDisplayVariableWithObject() { $db = eZDB::instance(); // STEP 1: Add test folder $folder = new ezpObject("folder", 2); $folder->name = __FUNCTION__; $folder->publish(); $nodeId = $folder->mainNode->node_id; $node = eZContentObjectTreeNode::fetch($nodeId); $attrOp = new eZTemplateAttributeOperator(); $outputTxt = ''; try { $attrOp->displayVariable($node, false, true, 2, 0, $outputTxt); } catch (PHPUnit_Framework_Error $e) { self::fail("eZTemplateAttributeOperator raises an error when working with objects."); } self::assertNotNull($outputTxt, "Output text is empty."); // this is an approxmiate test. The output shoudl contain the name of the object it has been generated correctly. self::assertContains(__FUNCTION__, $outputTxt, "There is something wrong with the output of the attribute operator. Object name not found."); }
/** * Unit test for eZContentObject::relatedObjects() * * Outline: * 1) Create a content class with ezobjectrelation attribute * 2) Create object of that class and relate to another object through the attribute * 3) Check that object loaded by eZContentObject::relatedObjects() is the correct one */ public function testRelatedObjectsWithAttributeId() { // Create a test content class $class = new ezpClass(__FUNCTION__, __FUNCTION__, 'name'); $class->add('Name', 'name', 'ezstring'); $attributeId = $class->add('Single relation #1', 'relation', 'ezobjectrelation')->attribute('id'); $class->store(); // Create an article we will relate our object to $article = new ezpObject('article', 2); $article->title = "Related object #1 for " . __FUNCTION__; $article->publish(); // Create a test object with attribute relation to created article $object = new ezpObject(__FUNCTION__, 2); $object->name = __FUNCTION__; $object->relation = $article->attribute('id'); $object->publish(); $contentObject = eZContentObject::fetch($object->attribute('id')); $relatedObjects = $contentObject->relatedObjects(false, false, $attributeId); $this->assertCount(1, $relatedObjects); $this->assertInstanceOf("eZContentObject", $relatedObjects[0]); $this->assertEquals($article->attribute('id'), $relatedObjects[0]->attribute("id"), "Related object is not the expected object"); }
} else { $exitStatus = 0; //Error code if you need to or whatever $myPid = getmypid(); // No need if the DB ain't initialized before forking $db = eZDB::instance(false, false, true); eZDB::setInstance($db); // suppress error output due to fatal DB errors // exceptions from the DB layer would allow for better information output fclose(STDERR); $object = new ezpObject($optContentClass, $optParentNode); $object->title = "Wait Timeout Test, pid {$myPid}\n"; if ($optGenerateContent === true) { $object->body = file_get_contents('xmltextsource.txt'); } $object->publish(); eZExecution::cleanExit(); } } } if ($script->verboseOutputLevel() > 0) { $cli->output("Main process: waiting for children..."); } $errors = 0; while (!empty($currentJobs)) { foreach ($currentJobs as $index => $pid) { if (pcntl_waitpid($pid, $exitStatus, WNOHANG) > 0) { $exitCode = pcntl_wexitstatus($exitStatus); if ($exitCode != 0) { $errors++; if (!$optQuiet) {
public function setUp() { parent::setUp(); if (!self::ldapIsEnabled()) { $this->markTestSkipped('LDAP is not loaded'); return; } // Setup the LDAP user data require_once 'tests/tests/kernel/datatypes/ezuser/setup_accounts.php'; // Setup user groups: // LDAP users // StarWars // RebelAlliance // Rogues // GalacticEmpire // Sith $this->mainGroup = new ezpObject('user_group', 5); $this->mainGroup->name = 'LDAP users'; $mainGroupObjId = $this->mainGroup->publish(); $this->mainGroupNodeId = $this->mainGroup->mainNode->node_id; $starWarsGroup = new ezpObject('user_group', (int) $this->mainGroupNodeId); $starWarsGroup->name = 'StarWars'; $starWarsGroup->publish(); $this->starWarsGroupNodeId = $starWarsGroup->mainNode->node_id; $rebelGroup = new ezpObject('user_group', (int) $this->starWarsGroupNodeId); $rebelGroup->name = 'RebelAlliance'; $rebelGroup->publish(); $this->rebelGroupNodeId = $rebelGroup->mainNode->node_id; $rogueGroup = new ezpObject('user_group', (int) $this->starWarsGroupNodeId); $rogueGroup->name = 'Rogues'; $rogueGroup->publish(); $this->rogueGroupNodeId = $rogueGroup->mainNode->node_id; $empireGroup = new ezpObject('user_group', (int) $this->starWarsGroupNodeId); $empireGroup->name = 'GalacticEmpire'; $empireGroup->publish(); $this->empireGroupNodeId = $empireGroup->mainNode->node_id; $sithGroup = new ezpObject('user_group', (int) $this->empireGroupNodeId); $sithGroup->name = 'Sith'; $sithGroup->publish(); $this->sithGroupNodeId = $sithGroup->mainNode->node_id; // Setup default settings, change these in each test when needed $this->ldapINI = eZINI::instance('ldap.ini'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPDebugTrace', 'disabled'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPVersion', 3); $this->ldapINI->setVariable('LDAPSettings', 'LDAPFollowReferrals', 0); $this->ldapINI->setVariable('LDAPSettings', 'LDAPEnabled', 'true'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPServer', 'phpuc.ez.no'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPPort', 389); $this->ldapINI->setVariable('LDAPSettings', 'LDAPBaseDn', 'dc--phpuc,dc--ez,dc--no'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPBindUser', ''); $this->ldapINI->setVariable('LDAPSettings', 'LDAPBindPassword', ''); $this->ldapINI->setVariable('LDAPSettings', 'LDAPSearchScope', 'sub'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPEqualSign', '--'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPSearchFilters', array()); $this->ldapINI->setVariable('LDAPSettings', 'LDAPLoginAttribute', 'uid'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPUserGroupType', 'id'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPUserGroup', array($mainGroupObjId)); $this->ldapINI->setVariable('LDAPSettings', 'LDAPGroupRootNodeId', $this->mainGroupNodeId); $this->ldapINI->setVariable('LDAPSettings', 'LDAPGroupMappingType', 'UseGroupAttribute'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPCreateMissingGroups', 'disabled'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPGroupBaseDN', 'dc--phpuc,dc--ez,dc--no'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPGroupClass', 'organizationalUnit'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPGroupNameAttribute', 'ou'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPGroupMemberAttribute', 'ou'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPGroupDescriptionAttribute', 'description'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPUserGroupMap', array()); $this->ldapINI->setVariable('LDAPSettings', 'LDAPUserGroupAttributeType', 'name'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPUserGroupAttribute', 'ou'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPFirstNameAttribute', 'givenname'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPFirstNameIsCommonName', 'false'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPLastNameAttribute', 'sn'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPEmailAttribute', 'mail'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPEmailEmptyAttributeSuffix', ''); $this->ldapINI->setVariable('LDAPSettings', 'Utf8Encoding', 'false'); $this->ldapINI->setVariable('LDAPSettings', 'KeepGroupAssignment', 'disabled'); }
/** * Creates an article in eZ Publish in the folder $folderId, * with title $articleTitle and summary $articleIntro and returns its ID. * * @param int $folderId * @param string $articleName * @param string $articleIntro * @return ezpObject */ public function createEZPArticle($folderId, $articleTitle, $articleIntro, $articleRemoteID) { $object = new ezpObject('article', $folderId); $object->title = $articleTitle; $object->intro = $articleIntro; $object->publish(); // Update object RemoteID $object->setAttribute('remote_id', $articleRemoteID); $object->store(); return $object; }
/** * Test for issue #14370: Inserting non break space doesn't work * * @note Test depends on template output!! * @link http://issues.ez.no/14370 */ public function testNonBreakSpace() { $xmlData = '<paragraph>esp ace</paragraph>'; // Step 1: Create folder $folder = new ezpObject("folder", 2); $folder->name = "Non breaking space Test"; $folder->short_description = $xmlData; $folder->publish(); $xhtml = $folder->short_description->attribute('output')->attribute('output_text'); self::assertEquals('<p>esp ace</p>', $xhtml); }
/** * Regression test for issue {@see #17632 http://issues.ez.no/17632} * * In a multi language environment, a node fetched with a language other than the prioritized one(s) will return the * URL alias in the prioritized language */ public function testIssue17632() { $bkpLanguages = eZContentLanguage::prioritizedLanguageCodes(); $strNameEngGB = __FUNCTION__ . " eng-GB"; $strNameFreFR = __FUNCTION__ . " fre-FR"; // add a secondary language $locale = eZLocale::instance( 'fre-FR' ); $translation = eZContentLanguage::addLanguage( $locale->localeCode(), $locale->internationalLanguageName() ); // set the prioritize language list to contain english // ezpINIHelper::setINISetting( 'site.ini', 'RegionalSettings', 'SiteLanguageList', array( 'fre-FR' ) ); eZContentLanguage::setPrioritizedLanguages( array( 'fre-FR' ) ); // Create an object with data in fre-FR and eng-GB $folder = new ezpObject( 'folder', 2, 14, 1, 'eng-GB' ); $folder->publish(); // Workaround as setting folder->name directly doesn't produce the expected result $folder->addTranslation( 'eng-GB', array( 'name' => $strNameEngGB ) ); $folder->addTranslation( 'fre-FR', array( 'name' => $strNameFreFR ) ); $nodeId = $folder->main_node_id; // fetch the node with no default parameters. Should return the french URL Alias $node = eZContentObjectTreeNode::fetch( $nodeId ); self::assertEquals( 'testIssue17632-fre-FR' , $node->attribute( 'url_alias' ) ); // fetch the node in english. Should return the english URL Alias $node = eZContentObjectTreeNode::fetch( $nodeId, 'eng-GB' ); self::assertEquals( 'testIssue17632-eng-GB' , $node->attribute( 'url_alias' ) ); ezpINIHelper::restoreINISettings(); eZContentLanguage::setPrioritizedLanguages( $bkpLanguages ); }
/** * Helper method that creates and returns a ezcontentobject of class 'link' * * @param string $url * @return ezcontentobject $link */ private function createNewLinkObject($url) { $link = new ezpObject("link", 2); $link->name = __FUNCTION__ . mt_rand(); $link->location = array("", $url); $link->publish(); return $link; }