Esempio n. 1
0
 public function __construct($params = NULL, $app = NULL)
 {
     parent::__construct($params, $app);
     $this->task = new model\Task(\Stream\App::getConnection());
     $this->templates->addFolder('task', __DIR__ . DIRECTORY_SEPARATOR . 'templates');
     $this->templates->addData(['scripts' => array_merge($this->_scripts, ['/js/tasks.js'])]);
 }
Esempio n. 2
0
 public function setUp()
 {
     // model will use be initialized with last successful connection
     App::getConnection('test_stream');
     $this->req = $this->getMockBuilder(Request::class)->getMock();
     $this->user = $this->getMockBuilder(model\User::class)->disableOriginalConstructor()->getMock();
     $this->controller = new Users\Controller();
     $this->controller->uses(new \Stream\Session());
     $this->controller->inject('params', []);
     $this->controller->uses(['Request', $this->req]);
     $this->controller->uses(['user', $this->user]);
 }
Esempio n. 3
0
 public function setUp()
 {
     Validator::init();
     // autoload class before using constants
     $dsl = ['tasks' => \modules\Tasks\Decorators\Task::class, [['id', F\FIXED | F\REQUIRED], ['title', F\REQUIRED], ['completed', F\BOOL], ['url', F\URL], ['user_id', F\FIXED | F\REQUIRED], ['deleted', F\USER], ['users as user' => \modules\Users\Decorators\User::class, [['id', F\FIXED], ['email', F\EMAIL | F\REQUIRED], ['password', F\REQUIRED]], 'user.id = tasks.user_id']]];
     $this->validator = new Validator($dsl);
     $pdo = \Stream\App::getConnection('test_stream');
     $this->sess = $this->getMockBuilder(\Stream\Session::class)->getMock();
     $this->validator->uses(['Session', $this->sess]);
     $this->validator->uses($pdo);
     $this->validator->uses(new \modules\Users\Decorators\User($pdo));
 }
Esempio n. 4
0
 /** Give some context to scenario */
 public function __construct()
 {
     $this->app = new App();
     $this->app->loadConfig();
     $this->pdo = App::getConnection('test_stream');
     $this->app->rest(['/acl/:action'], \modules\Acl\Controller::class);
     $this->acl = \Mockery::mock(Acl::class);
     $this->req = \Mockery::mock(Request::class);
     $this->sess = \Mockery::mock(Session::class);
     $this->app->inject('acl', $this->acl);
     $this->app->inject('request', $this->req);
     $this->app->inject('session', $this->sess);
     $this->app->service('QueryBuilder', function ($pdo, $structure) {
         return new \Stream\Util\QueryBuilder($pdo, $structure);
     });
 }
Esempio n. 5
0
 public function testConnect()
 {
     $this->app = App::getInstance();
     $this->app->loadConfig();
     $this->assertInstanceOf(App::class, $this->app);
     // expects correct default database setup
     try {
         $this->app->connect();
     } catch (\PDOException $e) {
         $this->markTestIncomplete($e->getMessage());
     }
     $this->assertInstanceOf(PDO::class, $this->app->pdo);
     $this->app->connect('test_stream');
     $this->assertInstanceOf(PDO::class, $this->app->pdo);
     $this->expectException(Exception::class);
     $this->app->connect('not_existing_database_configuration_key');
 }
Esempio n. 6
0
 public function getConnection()
 {
     $this->pdo = \Stream\App::getConnection('test_stream');
     return $this->createDefaultDBConnection($this->pdo);
 }
Esempio n. 7
0
 public function setUp()
 {
     $this->pdo = \Stream\App::getConnection('test_stream');
     $this->dsl = ['tasks', ['id', PDO::PARAM_INT], ['title', PDO::PARAM_STR], ['description', PDO::PARAM_STR], ['users as user', [['id', PDO::PARAM_INT], ['email', PDO::PARAM_STR]], 'user.id = tasks.user_id'], ['users as delegate', [['id', PDO::PARAM_INT], ['email', PDO::PARAM_STR]], 'delegate.id = tasks.delegate_id']];
     $this->builder = new QueryBuilder($this->pdo, $this->dsl);
 }
Esempio n. 8
0
 public function setUp()
 {
     parent::setUp();
     $this->task = new \modules\Tasks\Decorators\Task(\Stream\App::getConnection('test_stream'));
 }
Esempio n. 9
0
 public function __construct($params = NULL, \Stream\App $app = NULL)
 {
     parent::__construct($params, $app);
     $this->user = new User(\Stream\App::getConnection());
     $this->u = new Decorators\User(\Stream\App::getConnection());
 }
Esempio n. 10
0
 public function __construct($params = NULL, $app = NULL)
 {
     parent::__construct($params, $app);
     $this->model = new model\Task(\Stream\App::getConnection());
 }