/** * Unit test for eZPolicy::saveTemporary() */ public function testSaveTemporary() { // Get the first policy from the anonymous role $policyList = $this->getRole()->policyList(); $policy = current($policyList); $originalPolicyID = $policy->attribute('id'); // The first fetch should create the temporary copy $temporaryPolicy = eZPolicy::fetchTemporaryCopy($policy->attribute('id')); $temporaryPolicy->saveTemporary(); // Check that the temporary policy has been moved to original $this->assertEquals(0, $temporaryPolicy->attribute('original_id')); // Check that the source policy has been removed $oldPolicy = eZPolicy::fetch($originalPolicyID); $this->assertNull($oldPolicy); }
<?php /** * @copyright Copyright (C) 1999-2011 eZ Systems AS. All rights reserved. * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2 * @version //autogentag// * @package kernel */ $Module = $Params['Module']; $policyID = $Params['PolicyID']; $policy = eZPolicy::fetchTemporaryCopy( $policyID ); $policyID = $policy->attribute( 'id' ); $originalPolicyID = $policy->attribute( 'original_id' ); if( $policy === null ) { return $Module->handleError( eZError::KERNEL_NOT_AVAILABLE, 'kernel' ); } $currentModule = $policy->attribute( 'module_name' ); $currentFunction = $policy->attribute( 'function_name' ); $roleID = $policy->attribute( 'role_id' ); $role = eZRole::fetch( $roleID ); $roleName = $role->attribute( 'name' ); $limitationValueList = $policy->limitationList(); $nodeList = array(); $subtreeList = array(); if ( $currentModule == '*' ) {