public function testMake() { \Mockery::mock('alias:Illuminate\\Support\\Facades\\Log')->shouldReceive('debug'); $qparams = ['filter' => (object) ['fields' => [(object) ['name' => 'email', 'value' => 'test', 'operator' => '<='], (object) ['name' => 'country', 'value' => 'Italy', 'operator' => 'like']]], 'sort' => (object) ['field' => 'foo', 'direction' => 'asc']]; $qparams = json_encode((object) $qparams); $query = \Foothing\Request\Laravel\RemoteQuery::spawn($qparams); $criteria = (new \Foothing\Repository\Eloquent\EloquentCriteria())->make($query); $this->assertEquals(2, count($criteria->filters)); $this->assertEquals('email', $criteria->filters[0]->field); $this->assertEquals('test', $criteria->filters[0]->value); $this->assertEquals('<=', $criteria->filters[0]->operator); $this->assertEquals('foo', $criteria->orderBy); $this->assertEquals('asc', $criteria->sortDirection); }
protected function spawn($qparams) { $qparams = json_encode((object) $qparams); return RemoteQuery::spawn($qparams); }