Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

Commit

Permalink
Merge pull request #248 from dongilbert/RemoveFactoryEntirely
Browse files Browse the repository at this point in the history
Remove all remnants of JFactory.
  • Loading branch information
David Hurley committed Oct 22, 2013
2 parents 1c68013 + 305edce commit ccedd06
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 674 deletions.
8 changes: 4 additions & 4 deletions src/Joomla/Database/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The `quote` method will escape a string and wrap it in quotes, however, the esca
function search($title)
{
// Get the database driver from the factory, or by some other suitable means.
$db = JFactory::getDbo();
$db = DatabaseDriver::getInstance($options);

// Search for an exact match of the title, correctly sanitising the untrusted input.
$sql1 = 'SELECT * FROM #__content WHERE title = ' . $db->quote($title);
Expand Down Expand Up @@ -95,9 +95,9 @@ These shorthand versions are also available when using the `Database\DatabaseQue
The `Database\DatabaseIterator` class allows iteration over database results

```php
$dbo = JFactory::getDbo();
$iterator = $dbo->setQuery(
$dbo->getQuery(true)->select('*')->from('#__content')
$db = DatabaseDriver::getInstance($options);
$iterator = $db->setQuery(
$db->getQuery(true)->select('*')->from('#__content')
)->getIterator();

foreach ($iterator as $row)
Expand Down
156 changes: 0 additions & 156 deletions src/Joomla/Database/Tests/DatabaseCase.php

This file was deleted.

3 changes: 2 additions & 1 deletion src/Joomla/Database/Tests/DatabaseFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

use Joomla\Database\DatabaseFactory;
use Joomla\Test\TestHelper;
use Joomla\Test\TestDatabase;

/**
* Test class for Joomla\Database\DatabaseFactory.
*
* @since 1.0
*/
class DatabaseFactoryTest extends DatabaseCase
class DatabaseFactoryTest extends TestDatabase
{
/**
* Object being tested
Expand Down
32 changes: 8 additions & 24 deletions src/Joomla/Database/Tests/DatabaseMysqlCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,22 @@

namespace Joomla\Database\Tests;

use Joomla\Factory;
use Joomla\Test\TestDatabase;
use Joomla\Database\DatabaseDriver;

/**
* Abstract test case class for MySQL database testing.
*
* @since 1.0
*/
abstract class DatabaseMysqlCase extends DatabaseCase
abstract class DatabaseMysqlCase extends TestDatabase
{
/**
* @var \Joomla\Database\Mysql\MysqlDriver The active database driver being used for the tests.
* @since 1.0
*/
protected static $driver;

/**
* @var array The database driver options for the connection.
* @since 1.0
*/
private static $options = array('driver' => 'mysql');

/**
* @var \Joomla\Database\Mysql\MysqlDriver The saved database driver to be restored after these tests.
* @since 1.0
*/
private static $stash;

/**
* This method is called before the first test of this test class is run.
*
Expand Down Expand Up @@ -88,7 +77,7 @@ public static function setUpBeforeClass()
try
{
// Attempt to instantiate the driver.
self::$driver = \Joomla\Database\DatabaseDriver::getInstance(self::$options);
self::$driver = DatabaseDriver::getInstance(self::$options);
}
catch (\RuntimeException $e)
{
Expand All @@ -100,23 +89,18 @@ public static function setUpBeforeClass()
{
self::$driver = null;
}

// Setup the factory pointer for the driver and stash the old one.
self::$stash = Factory::$database;
Factory::$database = self::$driver;
}

/**
* This method is called after the last test of this test class is run.
* Gets the data set to be loaded into the database during setup
*
* @return void
* @return \PHPUnit_Extensions_Database_DataSet_XmlDataSet
*
* @since 1.0
*/
public static function tearDownAfterClass()
protected function getDataSet()
{
Factory::$database = self::$stash;
self::$driver = null;
return $this->createXMLDataSet(__DIR__ . '/Stubs/database.xml');
}

/**
Expand Down
32 changes: 8 additions & 24 deletions src/Joomla/Database/Tests/DatabaseMysqliCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,22 @@

namespace Joomla\Database\Tests;

use Joomla\Factory;
use Joomla\Test\TestDatabase;
use Joomla\Database\DatabaseDriver;

/**
* Abstract test case class for MySQLi database testing.
*
* @since 1.0
*/
abstract class DatabaseMysqliCase extends DatabaseCase
abstract class DatabaseMysqliCase extends TestDatabase
{
/**
* @var \Joomla\Database\Mysqli\MysqliDriver The active database driver being used for the tests.
* @since 1.0
*/
protected static $driver;

/**
* @var array The database driver options for the connection.
* @since 1.0
*/
private static $options = array('driver' => 'mysqli');

/**
* @var \Joomla\Database\Mysqli\MysqliDriver The saved database driver to be restored after these tests.
* @since 1.0
*/
private static $stash;

/**
* This method is called before the first test of this test class is run.
*
Expand Down Expand Up @@ -88,7 +77,7 @@ public static function setUpBeforeClass()
try
{
// Attempt to instantiate the driver.
self::$driver = \Joomla\Database\DatabaseDriver::getInstance(self::$options);
self::$driver = DatabaseDriver::getInstance(self::$options);
}
catch (\RuntimeException $e)
{
Expand All @@ -100,23 +89,18 @@ public static function setUpBeforeClass()
{
self::$driver = null;
}

// Setup the factory pointer for the driver and stash the old one.
self::$stash = Factory::$database;
Factory::$database = self::$driver;
}

/**
* This method is called after the last test of this test class is run.
* Gets the data set to be loaded into the database during setup
*
* @return void
* @return \PHPUnit_Extensions_Database_DataSet_XmlDataSet
*
* @since 1.0
*/
public static function tearDownAfterClass()
protected function getDataSet()
{
Factory::$database = self::$stash;
self::$driver = null;
return $this->createXMLDataSet(__DIR__ . '/Stubs/database.xml');
}

/**
Expand Down
Loading

0 comments on commit ccedd06

Please sign in to comment.