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
 /**
  * Adds add callback to an asset file which already has some.
  */
 function testAssetfileCallbackAddToExisting()
 {
     $this->testAssetfileCallbackLoadFile();
     $assetFile = 'test/somehashhere/index.xml';
     $asset = new binarypool_asset($this->getDummyStorage(), $assetFile);
     $this->assertEqual(2, count($asset->getCallbacks()));
     $asset->addCallback('http://testing_this.local.ch/falsetest');
     $this->assertEqual(3, count($asset->getCallbacks()));
     // Save
     $xml = $asset->getXML();
     file_put_contents(binarypool_config::getRoot() . $assetFile, $xml);
     // Check that callbacks are loaded again
     $asset = new binarypool_asset($this->getDummyStorage(), $assetFile);
     $this->assertEqual($asset->getCallbacks(), array('http://testing_this.local.ch/', 'http://testing_this.local.ch/2', 'http://testing_this.local.ch/falsetest'));
 }