overrideProperty() public static method

public static overrideProperty ( ) : ConfigOverrideProperty
return Ouzo\Config\ConfigOverrideProperty
 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);
 }
示例#3
0
 /**
  * @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');
 }
示例#4
0
 /**
  * @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);
 }
示例#5
0
 /**
  * @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());
 }
示例#6
0
 /**
  * @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');
 }
示例#7
0
 /**
  * @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');
 }
示例#8
0
 /**
  * @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);
 }
示例#9
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');
 }
示例#10
0
 public function __construct()
 {
     Config::overrideProperty('namespace', 'controller')->with('\\');
     parent::__construct();
 }
示例#11
0
 public function setUp()
 {
     parent::setUp();
     Config::overrideProperty('path', 'view')->with('test\\src\\Ouzo\\Core\\View');
 }
示例#12
0
 /**
  * @test
  */
 public function shouldReturnAllConfigValues()
 {
     // given
     Config::overrideProperty('key')->with('value');
     //when
     $values = Config::all();
     //then
     $this->assertEquals('value', $values['key']);
     Config::clearProperty('key');
     // cleanup
 }
示例#13
0
 /**
  * @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'));
 }
示例#14
0
 /**
  * @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');
 }
示例#15
0
 /**
  * @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);
 }
示例#16
0
 public function setUp()
 {
     parent::setUp();
     Config::overrideProperty('namespace', 'controller')->with('\\Ouzo\\');
     $this->injector = new Injector();
 }