本文整理汇总了PHP中ezpObject类的典型用法代码示例。如果您正苦于以下问题:PHP ezpObject类的具体用法?PHP ezpObject怎么用?PHP ezpObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ezpObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDisplayVariableWithObject
/**
* 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." );
}
示例2: testFetchUserList
/**
* 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( 'nospam@ez.no', $list[0]['address'] );
}
示例3: testIssue14983
/**
* 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');
}
示例4: testIssue16078
/**
* 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();
}
示例5: testApprovalFatalErrorWhenMoving
/**
* 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();
}
示例6: testIssue18249
/**
* @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 );
}
示例7: testFetchChildListByVersionStatus
/**
* 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);
}
示例8: testUpdateAndPublishObject
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());
}
}
示例9: createImage
/**
* @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'));
}
示例10: createObjectForRelation
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();
}
示例11: createEZPArticle
/**
* 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;
}
示例12: testRemoveAssignments
/**
* 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." );
}
示例13: testIssue15263
/**
* 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'));
}
示例14: createObject
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();
}
示例15: testDataMapFreshOnCopyObject
/**
* 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");
}