Ejemplo n.º 1
0
 /**
  * Ensure that data from one call doesn't override data of the second call
  */
 function testTwoCallsOfCloneOneMetadataList()
 {
     // Common params
     $dstGroupId = '321';
     $metadataMapping = array();
     $metadataMapping['love'] = array();
     $findIter = new MockArrayIterator($this);
     $findIter->setReturnValue('count', 0);
     // Factory to test
     $srcMdF = new MetadataFactoryMockedForCloneOneMd($this);
     $eventManager = new MockEventManager($this);
     $srcMdF->setReturnReference('_getEventManager', $eventManager);
     // First Call setup
     $srcMd1 = new Docman_ListMetadata();
     $srcMd1->setId(301);
     $srcMd1->setType(PLUGIN_DOCMAN_METADATA_TYPE_LIST);
     $dstMdF1 = new MockDocman_MetadataFactory($this);
     $dstMdF1->setReturnValue('create', 401);
     $dstMdF1->expectOnce('create');
     $dstMdF1->setReturnValue('findByName', $findIter);
     $srcMdF->setReturnReferenceAt(0, '_getMetadataFactory', $dstMdF1);
     $dstLoveF1 = new MockDocman_MetadataListOfValuesElementFactory($this);
     $dstLoveF1->setReturnValue('cloneValues', array(101 => 201, 102 => 202));
     $srcMdF->setReturnReferenceAt(0, '_getListOfValuesElementFactory', $dstLoveF1);
     // Second call setup
     $srcMd2 = new Docman_ListMetadata();
     $srcMd2->setId(302);
     $srcMd2->setType(PLUGIN_DOCMAN_METADATA_TYPE_LIST);
     $dstMdF2 = new MockDocman_MetadataFactory($this);
     $dstMdF2->setReturnValue('create', 402);
     $dstMdF2->expectOnce('create');
     $dstMdF2->setReturnValue('findByName', $findIter);
     $srcMdF->setReturnReferenceAt(1, '_getMetadataFactory', $dstMdF2);
     $dstLoveF2 = new MockDocman_MetadataListOfValuesElementFactory($this);
     $dstLoveF2->setReturnValue('cloneValues', array(103 => 203, 104 => 204));
     $srcMdF->setReturnReferenceAt(1, '_getListOfValuesElementFactory', $dstLoveF2);
     // Run test
     $srcMdF->_cloneOneMetadata($dstGroupId, $srcMd1, $metadataMapping);
     $srcMdF->_cloneOneMetadata($dstGroupId, $srcMd2, $metadataMapping);
     $this->assertEqual($metadataMapping['md'][301], 401);
     $this->assertEqual($metadataMapping['md'][302], 402);
     $this->assertEqual($metadataMapping['love'][101], 201);
     $this->assertEqual($metadataMapping['love'][102], 202);
     $this->assertEqual($metadataMapping['love'][103], 203);
     $this->assertEqual($metadataMapping['love'][104], 204);
 }
 function testItemWithoutValueButWatermarkedValueDefined()
 {
     // No love for item
     $loveFactory = new MockDocman_MetadataListOfValuesElementFactory($this);
     // empty array because no value found
     $ai = new MockArrayIterator($this);
     $ai->setReturnValue('rewind', true);
     $ai->setReturnValue('valid', false);
     $loveFactory->setReturnValue('getLoveValuesForItem', $ai);
     //
     // But watermarked values is defined
     $dwmv = new MockDocmanWatermark_MetadataValue($this);
     $dwmv->setReturnValue('getWatermark', 1);
     $dwmv->setReturnValue('getValueId', 107);
     $ai = new MockArrayIterator($this);
     $ai->setReturnValue('rewind', true);
     $ai->setReturnValueAt(0, 'valid', true);
     $ai->setReturnValue('current', $dwmv);
     $ai->setReturnValueAt(1, 'valid', false);
     $dwmvf = new MockDocmanWatermark_MetadataValueFactory($this);
     $dwmvf->setReturnValue('getMetadataValuesIterator', $ai);
     // Setup class
     $dwmf = new DocmanWatermark_MetadataFactoryTestMetadataValueRetrieval($this);
     $dwmf->setReturnValue('getDocman_MetadataListOfValuesElementFactory', $loveFactory);
     $dwmf->setReturnValue('getDocmanWatermark_MetadataValueFactory', $dwmvf);
     // Parameters & Run
     $item = new MockDocman_Item($this);
     $item->setReturnValue('getId', 1789);
     $md = new MockDocman_Metadata($this);
     $md->setReturnValue('getId', 1871);
     $this->assertNull($dwmf->_getWatermarkingValues($item, $md));
 }