protected function setUp() { parent::setUp(); Route::clear(); $this->path = Path::joinWithTemp(uniqid() . '_generated_uri_helper.js'); Config::overrideProperty("global", "prefix_system")->with("/app"); }
/** * @test */ public function shouldCreateRendererAsSetInConfigurationForParticularViewEvenThoughDefaultRendererIsSpecified() { //given Config::overrideProperty('renderer', 'default')->with('DefaultRenderer'); Config::overrideProperty('renderer', 'my_view')->with('DummyRenderer'); //when $renderer = ViewRendererFactory::create('my_view', array()); //then $this->assertInstanceOf('DummyRenderer', $renderer); }
/** * @test */ public function shouldThrowExceptionForNonExistingLanguage() { //given Config::overrideProperty('language')->with('xx'); $i18n = new I18n(); //when CatchException::when($i18n)->t('product.description'); //then CatchException::assertThat()->isInstanceOf('Exception'); }
/** * @test */ public function shouldGetErrorWithClassForDebug() { //given Config::overrideProperty('debug')->with(true); $userException = new UserException('Winter is coming!'); //when $error = Error::forException($userException); //then $this->assertEquals('Ouzo\\UserException: Winter is coming!', $error->message); }
/** * @test */ public function shouldCreateProperSqlForSqlite() { //given Config::overrideProperty('sql_dialect')->with('\\Ouzo\\Db\\Dialect\\Sqlite3Dialect'); $restriction = Restrictions::regexp('value'); //when $sql = $restriction->toSql('key'); //then $this->assertEquals('key REGEXP ?', $sql); $this->assertEquals(array('value'), $restriction->getValues()); }
/** * @test */ public function shouldThrowConnectionExceptionFromForPostgres() { //given Config::overrideProperty('sql_dialect')->with('\\Ouzo\\Db\\Dialect\\PostgresDialect'); Mock::when($this->pdoMock)->errorInfo()->thenReturn(array('57P01', 7, 'Execution error')); $executor = StatementExecutor::prepare($this->dbMock, 'SELECT 1', array(), array()); //when CatchException::when($executor)->execute(); //then CatchException::assertThat()->isInstanceOf('\\Ouzo\\DbConnectionException'); Config::revertProperty('sql_dialect'); }
/** * @test */ public function shouldThrowExceptionWhenDialectAdapterNotExists() { //given Config::overrideProperty('sql_dialect')->with('\\Ouzo\\Tools\\Model\\Template\\MyImagineDialect'); //when try { new Generator('order_products'); $this->fail(); } catch (GeneratorException $e) { } //then Config::revertProperty('sql_dialect'); }
/** * @test */ public function shouldIgnoreDebugMessageIfDebugIsOff() { //given Config::overrideProperty('debug')->with(false); //when $this->logger->debug('My debug log line without params.'); //then $logContent = $this->_readStreamContent('test://stdout'); Assert::thatString($logContent)->hasSize(0); }
/** * @test */ public function shouldTranslateArrayWithPseudoLocalization() { //given Config::overrideProperty('pseudo_localization')->with(true); $labels = array('key' => array('k1' => 'value', 'k2' => 'other')); $translator = new Translator('en', $labels); //when $translation = $translator->translate('key'); //then $this->assertEquals(array('k1' => 'ṽȧŀŭḗ', 'k2' => 'ǿŧħḗř'), $translation); Config::clearProperty('pseudo_localization'); }
public function __construct() { Config::overrideProperty('namespace', 'controller')->with('\\'); parent::__construct(); }
public function setUp() { parent::setUp(); Config::overrideProperty('path', 'view')->with('test\\src\\Ouzo\\Core\\View'); }
/** * @test */ public function shouldReturnAllConfigValues() { // given Config::overrideProperty('key')->with('value'); //when $values = Config::all(); //then $this->assertEquals('value', $values['key']); Config::clearProperty('key'); // cleanup }
/** * @test */ public function shouldSaveStatsIfDebugIsOn() { //given Config::overrideProperty('debug')->with(true); Session::remove('stats_queries'); Route::get('/sample/save', 'sample#save'); //when $this->get('/sample/save'); //then $this->assertNotEmpty(Session::get('stats_queries')); }
/** * @test */ public function shouldRemoveNoticeIfFullUrlMatches() { //given Config::overrideProperty('global', 'prefix_system')->with('prefix'); Route::allowAll('/simple_test', 'simple_test'); $this->get('/simple_test/add_notice_for_full_url'); //when $this->get('/simple_test/read_kept'); $this->get('/simple_test/read_kept'); //then $this->assertRenderedContent()->isNull(); Config::revertProperty('global', 'prefix_system'); }
/** * @test */ public function shouldThrowOnBatchInsert() { //given $previous = Config::getValue('sql_dialect'); Config::overrideProperty('sql_dialect')->with('Ouzo\\Db\\Dialect\\MySqlDialect'); $inserter = new BatchInserter(); $inserter->add(new Product(array('name' => 'product1'))); //when CatchException::when($inserter)->execute(); //then CatchException::assertThat()->hasMessage("Batch insert not supported in mysql")->isInstanceOf('InvalidArgumentException'); Config::overrideProperty('sql_dialect')->with($previous); }
public function setUp() { parent::setUp(); Config::overrideProperty('namespace', 'controller')->with('\\Ouzo\\'); $this->injector = new Injector(); }