public function testCreateInvalidResultOrderDriver() { $this->swapConfig(['trucker::result_order.driver' => 'invalid']); Config::setApp($this->app); $this->setExpectedException('ReflectionException'); $this->setExpectedException('InvalidArgumentException'); $foo = ResultOrderFactory::build(); }
public function testFindAllWithGetParamsQueryConditionsAndGetOrderResults() { $this->setupIndividualTest($this->getTestOptions()); extract($this->getTestOptions()); $conditions = ConditionFactory::build(); $conditions->addCondition('name', '=', 'John Doe'); $conditions->addCondition('email', '=', '*****@*****.**'); $conditions->addCondition('id', '>=', 100); $conditions->setLogicalOperator($conditions->getLogicalOperatorAnd()); $this->assertEquals(http_build_query($conditions->toArray()), $conditions->toQueryString(), "Expected query string to look different"); $order = ResultOrderFactory::build(); $order->setOrderByField('email'); $order->setOrderDirection($order->getOrderDirectionDescending()); $this->assertEquals(http_build_query($order->toArray()), $order->toQueryString(), "Expected query string to look different"); $found = User::all($conditions, $order); $getParams = array_merge($conditions->toArray(), $order->toArray()); //get objects to assert on $history = $this->getHttpClientHistory(); $request = $history->getLastRequest(); $response = $history->getLastResponse(); $this->makeGuzzleAssertions('GET', $base_uri, $uri, $getParams); //assert that the HTTP RESPONSE is what is expected $this->assertTrue($response->isSuccessful()); $this->assertEquals($response_body, $response->getBody(true)); $this->assertTrue($found instanceof Collection); $this->assertEquals(5, $found->size(), "expected count is wrong"); $this->assertEquals(1234, $found->first()->id); $this->assertEquals('John Doe', $found->first()->name); }