Skip to content

Commit

Permalink
#165 - updated the ActiveRecordTest suite to test against MySQL as we…
Browse files Browse the repository at this point in the history
…ll as SQLite
  • Loading branch information
alphadevx committed Aug 18, 2015
1 parent 0fd30da commit e0c88e0
Show file tree
Hide file tree
Showing 5 changed files with 275 additions and 116 deletions.
4 changes: 2 additions & 2 deletions Alpha/Model/ActiveRecord.php
Expand Up @@ -208,7 +208,7 @@ public static function disconnect()
{
$config = ConfigProvider::getInstance();

$provider = ActiveRecordProviderFactory::getInstance($config->get('db.provider.name'), new Person());
$provider = ActiveRecordProviderFactory::getInstance($config->get('db.provider.name'));
$provider->disconnect();
}

Expand Down Expand Up @@ -2389,7 +2389,7 @@ public static function dropDatabase()
$config = ConfigProvider::getInstance();

$provider = ActiveRecordProviderFactory::getInstance($config->get('db.provider.name'), new Person());
$provider->createDatabase();
$provider->dropDatabase();
}
}

Expand Down
18 changes: 11 additions & 7 deletions Alpha/Model/ActiveRecordProviderFactory.php
Expand Up @@ -66,32 +66,36 @@ class ActiveRecordProviderFactory
* based on the name of the provider class supplied.
*
* @param $providerName The fully-qualified class name of the provider class.
* @param $BO The active record instance to pass to the persistance provider for mapping.
* @param $BO The (optional) active record instance to pass to the persistance provider for mapping.
* @throws Alpha\Exception\IllegalArguementException
* @return Alpha\Model\ActiveRecordProviderInterface
* @since 1.1
*/
public static function getInstance($providerName, $BO)
public static function getInstance($providerName, $BO = null)
{
if(self::$logger == null)
if(self::$logger == null) {
self::$logger = new Logger('ActiveRecordProviderFactory');
}

self::$logger->debug('>>getInstance(providerName=['.$providerName.'], BO=['.print_r($BO, true).'])');

$config = ConfigProvider::getInstance();

if(class_exists($providerName)) {
if (class_exists($providerName)) {

$instance = new $providerName;

if(!$instance instanceof ActiveRecordProviderInterface)
if (!$instance instanceof ActiveRecordProviderInterface) {
throw new IllegalArguementException('The class ['.$providerName.'] does not implement the expected ActiveRecordProviderInterface interface!');
}

$instance->setBO($BO);
if ($BO instanceof ActiveRecord) {
$instance->setBO($BO);
}

self::$logger->debug('<<getInstance: [Object '.$providerName.']');
return $instance;
}else{
} else {
throw new IllegalArguementException('The class ['.$providerName.'] is not defined anywhere!');
}

Expand Down

0 comments on commit e0c88e0

Please sign in to comment.