/**
  * This method is called before the first test of this test class is run.
  *
  * An example DSN would be: host=localhost;dbname=joomla_ut;user=utuser;pass=ut1234
  *
  * @return  void
  *
  * @since   12.1
  */
 public static function setUpBeforeClass()
 {
     // First let's look to see if we have a DSN defined or in the environment variables.
     if (!defined('JTEST_DATABASE_MYSQLI_DSN') && !getenv('JTEST_DATABASE_MYSQLI_DSN')) {
         static::markTestSkipped('The MySQLi driver is not configured.');
     }
     $dsn = defined('JTEST_DATABASE_MYSQLI_DSN') ? JTEST_DATABASE_MYSQLI_DSN : getenv('JTEST_DATABASE_MYSQLI_DSN');
     // First let's trim the mysql: part off the front of the DSN if it exists.
     if (strpos($dsn, 'mysql:') === 0) {
         $dsn = substr($dsn, 6);
     }
     // Split the DSN into its parts over semicolons.
     $parts = explode(';', $dsn);
     // Parse each part and populate the options array.
     foreach ($parts as $part) {
         list($k, $v) = explode('=', $part, 2);
         switch ($k) {
             case 'host':
                 self::$_options['host'] = $v;
                 break;
             case 'dbname':
                 self::$_options['database'] = $v;
                 break;
             case 'user':
                 self::$_options['user'] = $v;
                 break;
             case 'pass':
                 self::$_options['password'] = $v;
                 break;
         }
     }
     try {
         // Attempt to instantiate the driver.
         static::$driver = JDatabaseDriver::getInstance(self::$_options);
     } catch (RuntimeException $e) {
         static::$driver = null;
     }
     // If for some reason an exception object was returned set our database object to null.
     if (static::$driver instanceof Exception) {
         static::$driver = null;
     }
     // Setup the factory pointer for the driver and stash the old one.
     self::$_stash = JFactory::$database;
     JFactory::$database = static::$driver;
 }
 /**
  * This method is called after the last test of this test class is run.
  *
  * @return  void
  *
  * @since   12.1
  */
 public static function tearDownAfterClass()
 {
     JFactory::$database = self::$_stash;
     self::$driver = null;
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  */
 protected function setUp()
 {
     parent::setUp();
     // Register the object
     $this->object = new JSchemaChangeset(static::$driver, __DIR__ . '/stubs');
 }
 /**
  * Overrides the parent tearDown method.
  *
  * @return  void
  *
  * @see     PHPUnit_Framework_TestCase::tearDown()
  * @since   3.6
  */
 protected function tearDown()
 {
     unset($this->object);
     parent::tearDown();
 }