Esempio n. 1
0
 public function testAppGetAll()
 {
     include_once __DIR__ . '/fixtures/Dogs.php';
     $decoder = $this->getMockBuilder('Rest\\Decoder')->disableOriginalConstructor()->getMock();
     $decoder->expects($this->any())->method('getModel')->will($this->returnValue('dogs'));
     $decoder->expects($this->any())->method('getId')->will($this->returnValue(null));
     $decoder->expects($this->any())->method('getAction')->will($this->returnValue('get'));
     $decoder->expects($this->any())->method('getRequest')->will($this->returnValue(\Symfony\Component\HttpFoundation\Request::create('/dogs/?name=lassie')));
     $app = new App($decoder, new \PDO('sqlite::memory:'));
     $app->register('dogs', '\\App\\Dogs');
     $response = $app->getResponse();
     $this->assertEquals(json_encode(array(1, 2), true), $response->getContent());
     $this->assertEquals(200, $response->getStatusCode());
 }
Esempio n. 2
0
<?php

include __DIR__ . "/../vendor/autoload.php";
error_reporting(-1);
use Rest\App;
$app = App::create(new \PDO('sqlite::memory:'));
$app->register('dogs', '\\App\\Dogs');
$app->register('cats', '\\App\\Cats');
$app->getResponse()->send();