예제 #1
0
파일: JsonTest.php 프로젝트: letsdrink/ouzo
 /**
  * @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');
 }
예제 #2
0
 /**
  * @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));
 }
예제 #3
0
파일: Assert.php 프로젝트: letsdrink/ouzo
 /**
  * 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());
 }
예제 #4
0
 /**
  * @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'));
 }
예제 #5
0
파일: UriTest.php 프로젝트: letsdrink/ouzo
 /**
  * @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();
 }
예제 #6
0
 /**
  * @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));
 }