Example #1
0
 /**
  * Dispatch module/controllers
  */
 public function testControllerPage()
 {
     $this->getApp()->useLayout(false);
     $this->dispatchRouter('/test/closure/');
     $this->assertOk();
     $closure = Response::getBody();
     $this->assertInstanceOf('\\Closure', $closure);
     $this->expectOutputRegex('/Closure is back/');
     $closure();
 }
Example #2
0
 public function testCreateMusicianError()
 {
     $this->dispatchRouter('/musician/crud/', $this->invalidRecord, Http\Request::METHOD_POST);
     $response = Response::getBody()->toArray();
     $error = $response['errors'];
     $this->assertEquals(count($error), 1);
     $this->assertEquals('ConcertDate is required', $error['concertDate'][0]);
     $count = Db::fetchOne('SELECT count(*) FROM musician WHERE nickname = ?', ['uniqNickname']);
     $this->assertEquals($count, 0);
 }
Example #3
0
 /**
  * POST request with invalid data should return ERROR and information
  */
 public function testCreateValidationErrors()
 {
     $this->dispatchRouter('/test/rest/', ['name' => '', 'email' => ''], Http\Request::METHOD_POST);
     $this->assertNotNull(Response::getBody()->errors);
     $this->assertEquals(sizeof(Response::getBody()->errors), 2);
     $this->assertResponseCode(400);
 }
Example #4
0
 /**
  * PUT request with invalid data should return ERROR and information
  */
 public function testUpdateValidationErrors()
 {
     $this->dispatchRouter('/test/crud/', ['id' => 2, 'name' => '123456', 'email' => 'leonardo[at]turtles.ua'], Http\Request::METHOD_PUT);
     $this->assertNotNull(Response::getBody()->errors);
     $this->assertEquals(sizeof(Response::getBody()->errors), 2);
     $this->assertOk();
 }
Example #5
0
 /**
  * Execute a DOM query
  *
  * @param  string $path
  * @return Document\NodeList
  */
 private function query($path)
 {
     if (!$this->document) {
         $this->document = new Document(Response::getBody());
     }
     return Document\Query::execute($path, $this->document, Document\Query::TYPE_CSS);
 }
Example #6
0
 public function testLoginSuccess()
 {
     $this->dispatchRouter('api/login', ['login' => 'admin', 'password' => 'admin'], 'POST');
     $this->assertOk();
     $this->assertArrayHasKey('token', Response::getBody()->toArray());
 }