Beispiel #1
0
 function isShouldCondition()
 {
     $fixture = loadFixture('conditions');
     foreach ($fixture as $case) {
         $r = $this->lemmy->render($case[0], $case[1]);
         $this->expect($r)->toBe($case[2]);
     }
 }
Beispiel #2
0
 function test_loadFromFail()
 {
     $rootResponse = loadFixture('root_list_error.http');
     $http = new MockZipmark_Http();
     $http->returns('GET', $rootResponse, array('/', null));
     $client = new Zipmark_Client(null, null, null, $http);
     try {
         $allResources = $client->resources();
         $this->fail("Expected Zipmark_Error");
     } catch (Zipmark_Error $e) {
         $this->assertEqual($e->getMessage(), "Root response does not contain vendor_root");
         $this->pass("Received Zipmark_Error");
     }
 }
 public function testLoadPage()
 {
     $rootResponse = loadFixture('root_list.http');
     $responsePage1 = loadFixture('bills/list_p1_of_3.http');
     $responsePage3 = loadFixture('bills/list_p3_of_3.http');
     $http = new MockZipmark_Http();
     $http->returns('GET', $rootResponse, array('/', null));
     $http->returns('GET', $responsePage1, array('http://example.org/bills', null));
     $http->returns('GET', $responsePage3, array('http://example.org/bills?page=3', null));
     $client = new Zipmark_Client(null, null, null, $http);
     $bills = $client->bills->getAll();
     $this->assertEqual($bills->page(), 1);
     $bills->loadPage(3);
     $this->assertEqual($bills->page(), 3);
 }
 function testResourceCreateFail()
 {
     $rootResponse = loadFixture('root_list.http');
     $response = loadFixture('disbursements/create_fail.http');
     $disbursement_data = array('user_email' => '*****@*****.**', 'customer_id' => 'abc123');
     $disbursement_json = json_encode(array("disbursement" => $disbursement_data));
     $http = new MockZipmark_Http();
     $http->returns('GET', $rootResponse, array('/', null));
     $http->returns('POST', $response, array('http://example.org/disbursements', $disbursement_json));
     $client = new Zipmark_Client(null, null, null, $http);
     try {
         $client->disbursements->create($disbursement_data);
         $this->fail("Expected Zipmark_ValidationError");
     } catch (Zipmark_ValidationError $e) {
         $this->assertEqual($e->getMessage(), "disbursement - amount_cents: can't be blank");
         $this->pass("Received Zipmark_ValidationError");
     }
     $this->assertEqual($response->statusCode, 422);
 }
Beispiel #5
0
 public function testNextPrevEndOfList()
 {
     $rootResponse = loadFixture('root_list.http');
     $responsePage1 = loadFixture('bills/list_p1_of_3.http');
     $responsePage2 = loadFixture('bills/list_p2_of_3.http');
     $responsePage3 = loadFixture('bills/list_p3_of_3.http');
     $http = new MockZipmark_Http();
     $http->returns('GET', $rootResponse, array('/', null));
     $http->returns('GET', $responsePage1, array('http://example.org/bills', null));
     $http->returns('GET', $responsePage1, array('http://example.org/bills?page=1', null));
     $http->returns('GET', $responsePage2, array('http://example.org/bills?page=2', null));
     $http->returns('GET', $responsePage3, array('http://example.org/bills?page=3', null));
     $client = new Zipmark_Client(null, null, null, $http);
     $bills = $client->bills->getAll();
     $iterator = new Zipmark_Iterator($bills);
     $this->assertEqual($iterator->key(), 0);
     $this->assertEqual($bills->page(), 1);
     // Try to retrieve the item in position -1
     $prevBill = $iterator->prev();
     $currentBill = $iterator->current();
     $this->assertEqual($prevBill, null);
     $this->assertEqual($currentBill, null);
     $this->assertEqual($iterator->key(), -1);
     $this->assertEqual($bills->page(), 1);
     $iterator->rewind();
     $iterator->next();
     $iterator->next();
     $iterator->next();
     $iterator->next();
     $iterator->next();
     $iterator->next();
     $iterator->next();
     $this->assertEqual($iterator->key(), 7);
     $this->assertEqual($bills->page(), 3);
     // Try to retrieve the item in max + 1
     $nextBill = $iterator->next();
     $currentBill = $iterator->current();
     $this->assertEqual($nextBill, null);
     $this->assertEqual($currentBill, null);
     $this->assertEqual($iterator->key(), 8);
     $this->assertEqual($bills->page(), 3);
 }
Beispiel #6
0
 public function testCallgraphData()
 {
     loadFixture($this->profiles, 'tests/fixtures/results.json');
     Environment::mock(array('SCRIPT_NAME' => 'index.php', 'PATH_INFO' => '/', 'QUERY_STRING' => 'id=aaaaaaaaaaaaaaaaaaaaaaaa'));
     $this->runs->callgraphData();
     $response = $this->app->response();
     $this->assertEquals('application/json', $response['Content-Type']);
     $this->assertStringStartsWith('{"', $response->body());
 }
 function testResourceUpdateFail()
 {
     $rootResponse = loadFixture('root_list.http');
     $getResponse = loadFixture('bills/get.http');
     $putResponse = loadFixture('bills/update_fail_permissions.http');
     $http = new MockZipmark_Http();
     $http->returns('GET', $rootResponse, array('/', null));
     $http->returns('GET', $getResponse, array('http://example.org/bills/3caca1e0a68fa94d5bf073fdfc1ef9db2a1b', null));
     $client = new Zipmark_Client(null, null, null, $http);
     $bill = $client->bills->get('3caca1e0a68fa94d5bf073fdfc1ef9db2a1b');
     $bill->amount_cents = 314;
     $update_json = $bill->toJson();
     $http->returns('PUT', $putResponse, array('http://example.org/bills/3caca1e0a68fa94d5bf073fdfc1ef9db2a1b', $update_json));
     try {
         $bill->save();
         $this->fail("Expected Zipmark_PermissionError");
     } catch (Zipmark_PermissionError $e) {
         $this->assertEqual($e->getMessage(), "Permissions: Bill is not open");
         $this->pass("Received Zipmark_PermissionError");
     }
 }
 private function getTestServer($name)
 {
     return json_decode(file_get_contents(loadFixture('server', $name . '.json')));
 }
Beispiel #9
0
 public function setUp()
 {
     $di = Xhgui_ServiceContainer::instance();
     $this->profiles = $di['profiles'];
     loadFixture($this->profiles, 'tests/fixtures/results.json');
 }