/** * 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(); }
/** * 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(); }
/** * Tests a problem which arose when a combined URL entry, * representing several translations are split up, by one translation being * changed to to an earlier history entry, of that same entry. * * Note: __FUNCTION__ will be appended to every name/title attribute in order * to ensure they will be unique to this test */ function testURLAliasSplitParentTranslation() { ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'SiteLanguageList', array('eng-GB', 'nor-NO')); eZContentLanguage::clearPrioritizedLanguages(); $db = eZDB::instance(); // STEP 1: Add test folder $folder = new ezpObject("folder", 2); $folder->name = __FUNCTION__; $folder->publish(); // STEP 2: Add child below folder $child = new ezpObject("folder", $folder->mainNode->node_id); $child->name = "Child" . __FUNCTION__; $child->publish(); // Sub-sub children disabled for now, might be used in future, for // further assertions. // // STEP 2a: Add a sub-sub child // $subChild1 = new ezpObject( 'article', $child->mainNode->node_id ); // $subChild1->title = "SubChild"; // $subChild1->publish(); // // // STEP 2b: Add a sub-sub child // $subChild2 = new ezpObject( 'article', $child->mainNode->node_id ); // $subChild2->title = "SubChildOther"; // $subChild2->publish(); // // // STEP 2ba: Adding sub-sub child translation // $norSubChild2Trans = array( "title" => "SubChildOtherNor" ); // $subChild2->addTranslation( "nor-NO", $norSubChild2Trans ); // // // STEP 2c: Add a sub-sub child // $subChild3 = new ezpObject( 'article', $child->mainNode->node_id ); // $subChild3->title = "SubChildThird"; // $subChild3->publish(); // // // STEP 2ca: Addubg sub-sub child translation // $norSubChild3Trans = array( "title" => "SubChildThird" ); // $subChild3->addTranslation( "nor-NO", $norSubChild3Trans ); // STEP 3: Add translation to child with the same name $translationAttributes = array("name" => "Child" . __FUNCTION__); $child->addTranslation("nor-NO", $translationAttributes); // STEP 4: Update the translation $child->refresh(); $newVersion = $child->createNewVersion(false, true, 'nor-NO'); $norDataMap = $child->fetchDataMap($newVersion->attribute('version'), "nor-NO"); $norDataMap['name']->setAttribute('data_text', 'NorChildChanged' . __FUNCTION__); $norDataMap['name']->store(); ezpObject::publishContentObject($child->object, $newVersion); // STEP 5: $child->refresh(); $child->name = "Renamed child" . __FUNCTION__; $child->publish(); // STEP 6: $child->refresh(); $child->name = "Child changed" . __FUNCTION__; $child->publish(); // STEP 7: $child->refresh(); $newVersion = $child->createNewVersion(false, true, 'nor-NO'); $norDataMap = $child->fetchDataMap($newVersion->attribute('version'), "nor-NO"); $norDataMap['name']->setAttribute('data_text', 'NorChildChanged again' . __FUNCTION__); $norDataMap['name']->store(); ezpObject::publishContentObject($child->object, $newVersion); // STEP 8: $child->refresh(); $newVersion = $child->createNewVersion(false, true, 'nor-NO'); $norDataMap = $child->fetchDataMap($newVersion->attribute('version'), "nor-NO"); $norDataMap['name']->setAttribute('data_text', 'Child changed' . __FUNCTION__); $norDataMap['name']->store(); ezpObject::publishContentObject($child->object, $newVersion); // STEP 9: $child->refresh(); $newVersion = $child->createNewVersion(false, true, 'nor-NO'); $norDataMap = $child->fetchDataMap($newVersion->attribute('version'), "nor-NO"); $norDataMap['name']->setAttribute('data_text', 'NorChildChanged again' . __FUNCTION__); $norDataMap['name']->store(); ezpObject::publishContentObject($child->object, $newVersion); $query = self::buildSql(array($child->mainNode->node_id)); $result = $db->arrayQuery($query); $initialTranslationChild = self::urlEntryForName("Child-changed" . __FUNCTION__, $result); $translationChild = self::urlEntryForName('NorChildChanged-again' . __FUNCTION__, $result); self::assertEquals((int) $initialTranslationChild['id'], (int) $translationChild['id'], "Current translations of the same node need to have the same id."); ezpINIHelper::restoreINISettings(); }