Ejemplo n.º 1
0
 /**
  * Create a test asset file.
  *
  * @param $callbacks: Array of callbacks to register.
  * @param $age: Age of item in days.
  */
 function createAsset($callbacks = array(), $age = 30)
 {
     // Create asset file
     $asset = new binarypool_asset($this->getDummyStorage());
     $asset->setBasePath('test/somehashhere');
     $asset->setOriginal($this->testfile);
     $asset->setExpiry(time() - $age * 24 * 60 * 60);
     foreach ($callbacks as $callback) {
         $asset->addCallback($callback);
     }
     $xml = $asset->getXML();
     mkdir(self::$BUCKET . 'somehashhere', 0755, true);
     copy($this->testfile, self::$BUCKET . 'somehashhere/vw_golf.jpg');
     file_put_contents(self::$BUCKET . 'somehashhere/index.xml', $xml);
     return 'test/somehashhere/index.xml';
 }
Ejemplo n.º 2
0
 function testPDFAssetWithoutRenditions()
 {
     // Create asset file
     $asset = new binarypool_asset($this->getDummyStorage());
     $asset->setBasePath('test/somehashhere');
     $asset->setOriginal(realpath(dirname(__FILE__) . '/../res/emil_frey_logo_2.pdf'));
     $xml = $asset->getXML();
     // Load XML
     $dom = DOMDocument::loadXML($xml);
     $xp = new DOMXPath($dom);
     // Test
     $this->assertXPath($xp, '/registry/@version', '3.0');
     $this->assertXPath($xp, '/registry/items/item/@type', 'IMAGE');
     $this->assertXPath($xp, '/registry/items/item/@isRendition', 'false');
     $this->assertXPath($xp, '/registry/items/item/webobject/@unit', 'mm');
     $this->assertXPath($xp, '/registry/items/item/webobject/objectWidth', '203');
     $this->assertXPath($xp, '/registry/items/item/webobject/objectHeight', '40');
     $this->assertXPath($xp, '/registry/items/item/imageinfo/@isLandscape', 'true');
     $this->assertXPath($xp, '/registry/items/item/imageinfo/@unit', 'mm');
     $this->assertXPath($xp, '/registry/items/item/imageinfo/width', '203');
     $this->assertXPath($xp, '/registry/items/item/imageinfo/height', '40');
     $this->assertXPath($xp, '/registry/items/item/location', 'test/somehashhere/emil_frey_logo_2.pdf');
     $this->assertXPath($xp, '/registry/items/item/mimetype', 'application/pdf');
     $this->assertXPath($xp, '/registry/items/item/size', '28216');
 }
Ejemplo n.º 3
0
 /**
  * Checks the correct behaviour when updating an asset's expiry date.
  * The old symbolic link should be deleted and the new one created.
  */
 function testUpdateExpireDateView()
 {
     // Paths to assert against
     $date = date('Y/m/d', strtotime('+2 days'));
     $viewExpires2Days = self::$BUCKET . 'expiry/' . $date . '/' . $this->assetId;
     $date = date('Y/m/d', strtotime('+9 days'));
     $viewExpires9Days = self::$BUCKET . 'expiry/' . $date . '/' . $this->assetId;
     $asset = new binarypool_asset($this->getDummyStorage(), $this->assetFile);
     $asset->setExpiry(strtotime('+2 days'));
     file_put_contents(binarypool_config::getRoot() . $this->assetFile, $asset->getXML());
     // First view correctly created?
     binarypool_views::created('test', $this->assetFile, array());
     $this->assertTrue(file_exists($viewExpires2Days), 'Asset was not put into the first expiration date view.');
     $this->assertTrue(file_exists($viewExpires2Days . '/index.xml'), 'Asset file does not exist in the first expiration date view.');
     // Update
     $oldAsset = new binarypool_asset($this->getDummyStorage(), $this->assetFile);
     $asset = new binarypool_asset($this->getDummyStorage(), $this->assetFile);
     $asset->setExpiry(strtotime('+9 days'));
     file_put_contents(binarypool_config::getRoot() . $this->assetFile, $asset->getXML());
     // Second view correctly created?
     binarypool_views::updated('test', $this->assetFile, $oldAsset);
     $this->assertTrue(file_exists($viewExpires9Days), 'Asset was not put into the new expiration date view.');
     $this->assertTrue(file_exists($viewExpires9Days . '/index.xml'), 'Asset file does not exist in the new expiration date view.');
     // First view correctly deleted?
     binarypool_views::created('test', $this->assetFile, array());
     $this->assertFalse(file_exists($viewExpires2Days), 'Asset was not deleted from the first expiration date view.');
 }