Exemplo n.º 1
0
 /**
  * @param       $verb
  * @param       $resource
  * @param array $query
  * @param null  $payload
  * @param array $header
  *
  * @return \DreamFactory\Core\Contracts\ServiceResponseInterface
  */
 protected function makeRequest($verb, $resource = null, $query = [], $payload = null, $header = [])
 {
     $request = new TestServiceRequest($verb, $query, $header);
     $request->setApiVersion('v1');
     if (!empty($payload)) {
         if (is_array($payload)) {
             $request->setContent($payload);
         } else {
             $request->setContent($payload, DataFormats::JSON);
         }
     }
     return $this->handleRequest($request, $resource);
 }
Exemplo n.º 2
0
 public function testCreateRecordFailMissingRequiredField()
 {
     $payload = '[{"complete":true}]';
     if (static::$wrapper) {
         $payload = '{' . static::$wrapper . ': ' . $payload . '}';
     }
     $request = new TestServiceRequest(Verbs::POST);
     $request->setContent($payload, DataFormats::JSON);
     $rs = $this->service->handleRequest($request, Table::RESOURCE_NAME . '/' . static::TABLE_NAME);
     $this->assertContains('{"error":{"context":null,"message":"Required field \'name\' can not be NULL.","code":400}}', $rs->getContent());
 }
Exemplo n.º 3
0
 public function testDeleteRecordsWithFields()
 {
     $payload = '[{"id":6},{"id":7}]';
     $request = new TestServiceRequest(Verbs::DELETE, [ApiOptions::FIELDS => 'name']);
     $request->setContent($payload, DataFormats::JSON);
     $rs = $this->service->handleRequest($request, Table::RESOURCE_NAME . '/' . static::TABLE_NAME);
     //        $this->assertEquals( '{"record":[{"id":2},{"id":3}]}', $rs->getContent() );
     $request->setMethod(Verbs::GET);
     try {
         $rs = $this->service->handleRequest($request, Table::RESOURCE_NAME . '/' . static::TABLE_NAME . '/6');
         $this->assertTrue(false);
     } catch (\Exception $ex) {
         $this->assertInstanceOf('\\DreamFactory\\Core\\Exceptions\\NotFoundException', $ex);
     }
     try {
         $rs = $this->service->handleRequest($request, Table::RESOURCE_NAME . '/' . static::TABLE_NAME . '/7');
         $this->assertTrue(false);
     } catch (\Exception $ex) {
         $this->assertInstanceOf('\\DreamFactory\\Core\\Exceptions\\NotFoundException', $ex);
     }
 }