public function testDbTableAbstractFactory__invokeIfConfigExist()
 {
     $createStatementStr = 'CREATE TEMPORARY TABLE IF NOT EXISTS test_res_tablle (id INT)';
     $createStatement = $this->adapter->query($createStatementStr);
     $createStatement->execute();
     $container = (include 'config/container.php');
     $requestedName = 'testDbTable';
     $result = $this->object->__invoke($container, $requestedName);
     $this->assertSame('zaboy\\rest\\DataStore\\DbTable', get_class($result));
 }
 public function testTableGatewayAbstractFactory__invokeIfTableAbsent()
 {
     $createStatementStr = 'CREATE TABLE IF NOT EXISTS tbl_name_which_exist (id INT)';
     $createStatement = $this->adapter->query($createStatementStr);
     $createStatement->execute();
     $requestedName = 'tbl_name_which_exist';
     $result = $this->object->__invoke($this->container, $requestedName);
     $this->assertSame('Zend\\Db\\TableGateway\\TableGateway', get_class($result));
     $createStatementStr = 'DROP TABLE IF EXISTS tbl_name_which_exist';
     $createStatement = $this->adapter->query($createStatementStr);
     $createStatement->execute();
 }
 public function testResponseEncoder__invoke()
 {
     $rowset = [1 => 'a', 2 => 'b'];
     $request = $this->request->withAttribute('Response-Body', $rowset);
     $contentRangeHeader = 'items 0-0/1';
     $response = $this->response->withHeader('Content-Range', $contentRangeHeader);
     $response = $response->withStatus(555);
     $response = $this->object->__invoke($request, $response, $this->next);
     $this->assertEquals($response->getBody()->__toString(), '{"1":"a","2":"b"}');
     $this->assertEquals($response->getStatusCode(), 555);
     $headers = $response->getHeaders();
     $this->assertEquals($headers['Content-Range'][0], "items 0-0/1");
     $this->assertEquals($headers['content-type'][0], "application/json");
 }
 public function testReturner__invoke()
 {
     $this->request = new ServerRequest([], [], '/foo');
     $returned = $this->object->__invoke($this->request, $this->response, $this->next);
     $this->assertSame($returned->getAttribute('Resource-Name'), 'foo');
     $this->assertSame($returned->getAttribute('id'), null);
     $this->request = new ServerRequest([], [], '/foo?a=3');
     $returned = $this->object->__invoke($this->request, $this->response, $this->next);
     $this->assertSame($returned->getAttribute('Resource-Name'), 'foo');
     $this->assertSame($returned->getAttribute('id'), null);
     $this->request = new ServerRequest([], [], 'foo/');
     $returned = $this->object->__invoke($this->request, $this->response, $this->next);
     $this->assertSame($returned->getAttribute('Resource-Name'), 'foo');
     $this->assertSame($returned->getAttribute('id'), null);
     $this->request = new ServerRequest([], [], '/foo/1662');
     $returned = $this->object->__invoke($this->request, $this->response, $this->next);
     $this->assertSame($returned->getAttribute('Resource-Name'), 'foo');
     $this->assertSame($returned->getAttribute('id'), '1662');
     $this->request = new ServerRequest([], [], '/foo/1t3?F=r');
     $returned = $this->object->__invoke($this->request, $this->response, $this->next);
     $this->assertSame($returned->getAttribute('Resource-Name'), 'foo');
     $this->assertSame($returned->getAttribute('id'), '1t3');
     $this->request = new ServerRequest([], [], 'foo/d_f-g1?');
     $returned = $this->object->__invoke($this->request, $this->response, $this->next);
     $this->assertSame($returned->getAttribute('Resource-Name'), 'foo');
     $this->assertSame($returned->getAttribute('id'), 'd_f-g1');
 }
 public function testResourceResolver__invokeResourceName5()
 {
     $this->request = new ServerRequest([], [], '/');
     $this->next = function ($req, $resp) {
         return $req;
     };
     $returnedResponse = $this->object->__invoke($this->request, $this->response, $this->next);
     $this->assertSame($returnedResponse->getAttribute('Resource-Name'), null);
     $this->assertSame($returnedResponse->getAttribute('Primary-Key-Value'), null);
 }
 public function testTableManagerMysql_foreign_key()
 {
     $this->object->rewriteTable('table_slave', 'test_config_table_slave');
     $this->object->rewriteTable('table_master', 'test_config_table_mastet');
     $this->assertSame('    With columns: ' . PHP_EOL . '        id -> int' . PHP_EOL . '        name -> varchar' . PHP_EOL . PHP_EOL . '    With constraints: ' . PHP_EOL . '        _zf_table_master_PRIMARY -> PRIMARY KEY' . PHP_EOL . '            column: id' . PHP_EOL . '        ForeignKey_table_master_name -> FOREIGN KEY' . PHP_EOL . '            column: name => table_slave.id' . PHP_EOL . '            OnDeleteRule: CASCADE' . PHP_EOL . '            OnUpdateRule: NO ACTION' . PHP_EOL, $this->object->getTableInfoStr('table_master'));
 }
 public function test__canCreateIfConfigAbsent()
 {
     $requestedName = 'the_name_which_has_not_config';
     $result = $this->object->canCreate($this->container, $requestedName);
     $this->assertSame(false, $result);
 }
 public function testDataStoreMemory__invoke()
 {
     $returnedResponse = $this->object->__invoke($this->request, $this->response, $this->next);
     $this->assertSame(get_class($returnedResponse->getAttribute('memoryStore')), 'zaboy\\rest\\DataStore\\Memory');
 }