/** * @test */ public function shouldDecodeJsonAsArray() { //given $json = '{"name":"john","id":123,"ip":"127.0.0.1"}'; //when $decoded = Json::safeDecode($json, true); //then ArrayAssert::that($decoded)->hasSize(3)->contains('john', 123, '127.0.0.1'); }
/** * @test */ public function shouldTraceInfoAboutHttpRequest() { //given $this->_createHttpTraceRequest('/request1', array('param1' => 1, 'param2' => 2)); //when $queries = Arrays::first(Stats::queries()); //then ArrayAssert::that($queries['request_params'][0])->hasSize(2)->containsKeyAndValue(array('param1' => 1, 'param2' => 2)); }
/** * Fluent custom session assertion to simplify your tests. * * Sample usage: * <code> * Session::push('key1', 'key2', 'value1'); * Assert::thatSession()->hasSize(1)->contains('value1'); * </code> * * Class Assert * @package Ouzo\Tests */ public static function thatSession() { return ArrayAssert::that(isset($_SESSION) ? $_SESSION : array()); }
/** * @test */ public function shouldFindRouteWithNamespace() { //given Route::post('/api/users/:id/archive', 'api/users#archive'); $router = $this->_createRouter('POST', '/api/users/12/archive'); //when $rule = $router->findRoute(); //then $this->assertEquals('api/users', $rule->getController()); $this->assertEquals('archive', $rule->getAction()); ArrayAssert::that($rule->getParameters())->hasSize(1)->containsKeyAndValue(array('id' => '12')); }
/** * @test */ public function shouldAcceptEmptyJson() { //given StreamStub::register('json'); StreamStub::$body = ''; ContentType::set('application/json'); //when $parameters = $this->getRequestParameters('json://input'); //then ArrayAssert::that($parameters)->hasSize(0); StreamStub::unregister(); }
/** * @test */ public function shouldTraceRequestInfo() { //given Config::overrideProperty('debug')->with(true); Route::resource('restful'); $this->get('/restful?param=1'); //when $queries = Arrays::first(Stats::queries()); //then ArrayAssert::that($queries['request_params'][0])->hasSize(1)->containsKeyAndValue(array('param' => 1)); }