/** * Tests retrieval of a non-existing URL. */ function testInvalidGet() { $this->get('/something/def'); $this->assertEqual(api_response::getInstance()->getCode(), 404); $this->assertText('/error/code', '100'); $this->assertText('/error/msg', 'Bucket not defined: something'); }
/** * HEAD on an asset file. */ function testAssetFile() { $this->upload(); $this->head('/test/09/096dfa489bc3f21df56eded2143843f135ae967e/index.xml'); $response = api_response::getInstance(); $this->assertEqual($response->getCode(), 200); $this->assertEqual('', $response->getContents()); }
/** * Check that the asset is actually deleted. */ function testDeleteAssetCheckDeleted() { $this->testDeleteAsset(); try { $this->get('/test/09/096dfa489bc3f21df56eded2143843f135ae967e/index.xml'); } catch (api_testing_exception $e) { // pass - not expecting response XML } $response = api_response::getInstance(); $this->assertEqual($response->getCode(), 404); }
/** * Override OKAPI implementation with one that raises exceptions * on empty XML */ protected function loadResponse() { $response = api_response::getInstance(); $resp = $response->getContents(); if (empty($resp)) { throw new api_testing_exception("Empty response document"); } $dom = new DOMDocument(); if (!$dom->loadXML($resp)) { throw new api_testing_exception(sprintf("Unable to load XML: '%s'", $resp)); } $this->responseDom = $dom; }
function __construct() { try { $this->request = api_request::getInstance(); // echo "<pre>"; // print_r( $this->request); $this->response = api_response::getInstance(); $this->loadRoutes(); } catch (api_exception $e) { $this->catchFinalException($e); } catch (Exception $e) { $this->catchFinalException($e); } }
/** * Touch the asset with a valid custom expiry date and make * sure the views are updated. */ function testTouchWithCustomExpiryDate() { $this->testDefaultExpiry(); // Touch with 3 days expiry date try { $this->post('/test/09/096dfa489bc3f21df56eded2143843f135ae967e/index.xml', array('TTL' => '3')); } catch (api_testing_exception $e) { // pass - not expecting response XML } $response = api_response::getInstance(); $this->assertEqual($response->getCode(), 204); $this->assertEqual('', $response->getContents()); // Check that old view is gone $date = date('Y/m/d', time() + 7 * 24 * 60 * 60); $this->head('/test/expiry/' . $date . '/096dfa489bc3f21df56eded2143843f135ae967e/index.xml'); $response = api_response::getInstance(); $this->assertEqual($response->getCode(), 404); // Check that new view is valid $date = date('Y/m/d', time() + 3 * 24 * 60 * 60); $this->head('/test/expiry/' . $date . '/096dfa489bc3f21df56eded2143843f135ae967e/index.xml'); $response = api_response::getInstance(); $this->assertEqual($response->getCode(), 200); }
/** * Tests if we get a correct error for a hash which does not exist. * This test goes to the directory instead of the asset file. */ function testHeadNonexistingDirectoryHash() { $this->head('/test/sha1/abcdefghijklmnopqrstuvwxyzabcdefghijklmn'); $response = api_response::getInstance(); $this->assertEqual($response->getCode(), 404); $this->assertEqual('', $response->getContents()); }
/** * Tests that the correct rendition is saved. */ function testUploadRenditionVerify() { $this->testUploadRendition(); $this->get('/test/cb/cbf9f9f453acaba556e00b48951815da5611f975/index.xml'); $this->assertEqual(api_response::getInstance()->getCode(), 200); $localHash = sha1_file(dirname(__FILE__) . '/../res/vw_golf_blur.jpg'); $remoteFile = $this->getText('/registry/items/item[rendition="detailpage"]/location'); $remoteHash = sha1_file(binarypool_config::getRoot() . '/' . $remoteFile); $this->assertEqual($localHash, $remoteHash); }