/**
  * Setup.
  *
  * @return void
  */
 protected function setUp()
 {
     require_once dirname(__DIR__) . '/storage/JCacheStorageMock.php';
     require_once __DIR__ . '/JCacheControllerCallback.helper.php';
     // Some tests are affected by the output of the logger, so we clear the logger here.
     JLog::setInstance(null);
 }
 public function setUp()
 {
     //require_once dirname(dirname(dirname(dirname(dirname(__DIR__))))).'/bootstrap.php';
     jimport('joomla.cache.cache');
     require_once dirname(__DIR__) . '/storage/JCacheStorageMock.php';
     require_once __DIR__ . '/JCacheControllerCallback.helper.php';
     // some tests are affected by the output of the logger, so we clear the logger here.
     JLog::setInstance(null);
 }
示例#3
0
 /**
  * Test the JLog::setInstance method to make sure that if we set a logger instance JLog is actually going
  * to use it.  We accomplish this by setting an instance of JLogInspector and then performing some
  * operations using JLog::addLogger() to alter the state of the internal instance.  We then check that the
  * JLogInspector instance we created (and set) has the same values we would expect for lookup and configuration
  * so we can assert that the operations we performed using JLog::addLogger() were actually performed on our
  * instance of JLogInspector that was set.
  *
  * @return  void
  *
  * @since   11.1
  */
 public function testSetInstance()
 {
     $log = new JLogInspector();
     JLog::setInstance($log);
     // Add a logger to the JLog object.
     JLog::addLogger(array('logger' => 'w3c'));
     // Get the expected configurations array after adding the single logger.
     $expectedConfigurations = array('55202c195e23298813df4292c827b241' => array('logger' => 'w3c'));
     // Get the expected lookup array after adding the single logger.
     $expectedLookup = array('55202c195e23298813df4292c827b241' => (object) array('priorities' => JLog::ALL, 'categories' => array(), 'exclude' => false));
     // Get the expected loggers array after adding the single logger (hasn't been instantiated yet so null).
     $expectedLoggers = null;
     $this->assertThat($log->configurations, $this->equalTo($expectedConfigurations), 'Line: ' . __LINE__ . '.');
     $this->assertThat($log->lookup, $this->equalTo($expectedLookup), 'Line: ' . __LINE__ . '.');
     $this->assertThat($log->loggers, $this->equalTo($expectedLoggers), 'Line: ' . __LINE__ . '.');
     // Start over so we test that it actually sets the instance appropriately.
     $log = new JLogInspector();
     JLog::setInstance($log);
     // Add a logger to the JLog object.
     JLog::addLogger(array('logger' => 'database', 'db_type' => 'mysql', 'db_table' => '#__test_table'), JLog::ERROR);
     // Get the expected configurations array after adding the single logger.
     $expectedConfigurations = array('b67483f5ba61450d173aae527fa4163f' => array('logger' => 'database', 'db_type' => 'mysql', 'db_table' => '#__test_table'));
     // Get the expected lookup array after adding the single logger.
     $expectedLookup = array('b67483f5ba61450d173aae527fa4163f' => (object) array('priorities' => JLog::ERROR, 'categories' => array(), 'exclude' => false));
     // Get the expected loggers array after adding the single logger (hasn't been instantiated yet so null).
     $expectedLoggers = null;
     $this->assertThat($log->configurations, $this->equalTo($expectedConfigurations), 'Line: ' . __LINE__ . '.');
     $this->assertThat($log->lookup, $this->equalTo($expectedLookup), 'Line: ' . __LINE__ . '.');
     $this->assertThat($log->loggers, $this->equalTo($expectedLoggers), 'Line: ' . __LINE__ . '.');
 }
 /**
  * Test the JLog::setInstance method to make sure that if we set a logger instance JLog is actually going
  * to use it.  We accomplish this by setting an instance of JLogInspector and then performing some
  * operations using JLog::addLogger() to alter the state of the internal instance.  We then check that the
  * JLogInspector instance we created (and set) has the same values we would expect for lookup and configuration
  * so we can assert that the operations we performed using JLog::addLogger() were actually performed on our
  * instance of JLogInspector that was set.
  *
  * @return  void
  *
  * @since   11.1
  */
 public function testSetInstance()
 {
     $log = new JLogInspector();
     JLog::setInstance($log);
     // Add a logger to the JLog object.
     JLog::addLogger(array('logger' => 'w3c'));
     // Get the expected configurations array after adding the single logger.
     $expectedConfigurations = array('55202c195e23298813df4292c827b241' => array('logger' => 'w3c'));
     // Get the expected lookup array after adding the single logger.
     $expectedLookup = array('55202c195e23298813df4292c827b241' => (object) array('priorities' => JLog::ALL, 'categories' => array(), 'exclude' => false));
     // Get the expected loggers array after adding the single logger (hasn't been instantiated yet so null).
     $expectedLoggers = null;
     $this->assertEquals($expectedConfigurations, $log->configurations);
     $this->assertEquals($expectedLookup, $log->lookup);
     $this->assertEquals($expectedLoggers, $log->loggers);
     // Start over so we test that it actually sets the instance appropriately.
     $log = new JLogInspector();
     JLog::setInstance($log);
     // Add a logger to the JLog object.
     JLog::addLogger(array('logger' => 'database', 'db_type' => 'mysqli', 'db_table' => '#__test_table'), JLog::ERROR);
     // Get the expected configurations array after adding the single logger.
     $expectedConfigurations = array('2c6b1817bcb404c50f7bbbe9e6ae1429' => array('logger' => 'database', 'db_type' => 'mysqli', 'db_table' => '#__test_table'));
     // Get the expected lookup array after adding the single logger.
     $expectedLookup = array('2c6b1817bcb404c50f7bbbe9e6ae1429' => (object) array('priorities' => JLog::ERROR, 'categories' => array(), 'exclude' => false));
     // Get the expected loggers array after adding the single logger (hasn't been instantiated yet so null).
     $expectedLoggers = null;
     $this->assertEquals($expectedConfigurations, $log->configurations);
     $this->assertEquals($expectedLookup, $log->lookup);
     $this->assertEquals($expectedLoggers, $log->loggers);
 }