create() public method

Create function used to POST.
public create ( object $query, array $options = [] ) : mixed
$query object
$options array
return mixed
Beispiel #1
0
 public function testCreateWithModel()
 {
     $model = $this->_model;
     $model::config(array('meta' => array('key' => 'id')));
     $http = new Http($this->_testConfig);
     $query = new Query(compact('model') + array('data' => array('title' => 'Test Title')));
     $result = $http->create($query);
     $expected = join("\r\n", array('POST /posts HTTP/1.1', 'Host: localhost:80', 'Connection: Close', 'User-Agent: Mozilla/5.0', 'Content-Type: application/x-www-form-urlencoded', 'Content-Length: 16', '', 'title=Test+Title'));
     $result = (string) $http->last->request;
     $this->assertEqual($expected, $result);
 }
Beispiel #2
0
 public function testCreateWithModel()
 {
     $http = new Http($this->_testConfig);
     $query = new Query(array('model' => '\\lithium\\tests\\mocks\\data\\source\\MockHttpModel', 'data' => array('title' => 'Test Title')));
     $result = $http->create($query);
     $expected = join("\r\n", array('POST /posts HTTP/1.1', 'Host: localhost:80', 'Connection: Close', 'User-Agent: Mozilla/5.0', 'Content-Type: application/x-www-form-urlencoded', 'Content-Length: 16', '', 'title=Test+Title'));
     $result = (string) $http->last->request;
     $this->assertEqual($expected, $result);
 }