Permalink
Browse files

Use __DIR__, not dirname(__FILE__).

  • Loading branch information...
faulkner committed Feb 17, 2011
1 parent ebb6ec7 commit 6949f8a4fcdffe40d10de59fda3c53e6b6dbbc12
@@ -1,10 +1,10 @@
<?php
-require_once dirname(__FILE__) . '/../../ActiveRecord.php';
+require_once __DIR__ . '/../../ActiveRecord.php';
// initialize ActiveRecord
ActiveRecord\Config::initialize(function($cfg)
{
- $cfg->set_model_directory(dirname(__FILE__) . '/models');
+ $cfg->set_model_directory(__DIR__ . '/models');
$cfg->set_connections(array('development' => 'mysql://test:test@127.0.0.1/orders_test'));
// you can change the default connection with the below
@@ -1,5 +1,5 @@
<?php
-require_once dirname(__FILE__) . '/../../ActiveRecord.php';
+require_once __DIR__ . '/../../ActiveRecord.php';
// assumes a table named "books" with a pk named "id"
// see simple.sql
@@ -1,5 +1,5 @@
<?php
-require_once dirname(__FILE__) . '/../../ActiveRecord.php';
+require_once __DIR__ . '/../../ActiveRecord.php';
class Book extends ActiveRecord\Model
{
View
@@ -26,7 +26,7 @@ public static function initialize($url, $options=array())
$url = parse_url($url);
$file = ucwords(Inflector::instance()->camelize($url['scheme']));
$class = "ActiveRecord\\$file";
- require_once dirname(__FILE__) . "/cache/$file.php";
+ require_once __DIR__ . "/cache/$file.php";
static::$adapter = new $class($url);
}
else
View
@@ -121,7 +121,7 @@ private static function load_adapter_class($adapter)
{
$class = ucwords($adapter) . 'Adapter';
$fqclass = 'ActiveRecord\\' . $class;
- $source = dirname(__FILE__) . "/adapters/$class.php";
+ $source = __DIR__ . "/adapters/$class.php";
if (!file_exists($source))
throw new DatabaseException("$fqclass not found!");
View
@@ -1,6 +1,6 @@
<?php
include 'helpers/config.php';
-require_once dirname(__FILE__) . '/../lib/Inflector.php';
+require_once __DIR__ . '/../lib/Inflector.php';
class InflectorTest extends SnakeCase_PHPUnit_Framework_TestCase
{
@@ -2,7 +2,7 @@
use ActiveRecord\Column;
include 'helpers/config.php';
-require_once dirname(__FILE__) . '/../lib/adapters/MysqlAdapter.php';
+require_once __DIR__ . '/../lib/adapters/MysqlAdapter.php';
class MysqlAdapterTest extends AdapterTest
{
View
@@ -1,6 +1,6 @@
<?php
include 'helpers/config.php';
-require_once dirname(__FILE__) . '/../lib/adapters/OciAdapter.php';
+require_once __DIR__ . '/../lib/adapters/OciAdapter.php';
class OciAdapterTest extends AdapterTest
{
@@ -2,7 +2,7 @@
use ActiveRecord\Column;
include 'helpers/config.php';
-require_once dirname(__FILE__) . '/../lib/adapters/PgsqlAdapter.php';
+require_once __DIR__ . '/../lib/adapters/PgsqlAdapter.php';
class PgsqlAdapterTest extends AdapterTest
{
@@ -1,6 +1,6 @@
<?php
include 'helpers/config.php';
-require_once dirname(__FILE__) . '/../lib/adapters/SqliteAdapter.php';
+require_once __DIR__ . '/../lib/adapters/SqliteAdapter.php';
class SqliteAdapterTest extends AdapterTest
{
@@ -26,7 +26,7 @@ public function testConnectToInvalidDatabaseShouldNotCreateDbFile()
}
catch (ActiveRecord\DatabaseException $e)
{
- $this->assertFalse(file_exists(dirname(__FILE__) . "/" . self::InvalidDb));
+ $this->assertFalse(file_exists(__DIR__ . "/" . self::InvalidDb));
}
}
@@ -78,7 +78,7 @@ public function get_fixture_tables()
{
$tables = array();
- foreach (glob(dirname(__FILE__) . '/../fixtures/*.csv') as $file)
+ foreach (glob(__DIR__ . '/../fixtures/*.csv') as $file)
{
$info = pathinfo($file);
$tables[] = $info['filename'];
@@ -89,7 +89,7 @@ public function get_fixture_tables()
public function get_sql($file)
{
- $file = dirname(__FILE__) . "/../sql/$file.sql";
+ $file = __DIR__ . "/../sql/$file.sql";
if (!file_exists($file))
throw new Exception("File not found: $file");
@@ -99,7 +99,7 @@ public function get_sql($file)
public function load_fixture_data($table)
{
- $fp = fopen(dirname(__FILE__) . "/../fixtures/$table.csv",'r');
+ $fp = fopen(__DIR__ . "/../fixtures/$table.csv",'r');
$fields = fgetcsv($fp);
if (!empty($fields))
View
@@ -13,7 +13,7 @@
require_once 'SnakeCase_PHPUnit_Framework_TestCase.php';
require_once 'DatabaseTest.php';
require_once 'AdapterTest.php';
-require_once dirname(__FILE__) . '/../../ActiveRecord.php';
+require_once __DIR__ . '/../../ActiveRecord.php';
// whether or not to run the slow non-crucial tests
$GLOBALS['slow_tests'] = false;
@@ -27,7 +27,7 @@
ActiveRecord\Config::initialize(function($cfg)
{
- $cfg->set_model_directory(realpath(dirname(__FILE__) . '/../models'));
+ $cfg->set_model_directory(realpath(__DIR__ . '/../models'));
$cfg->set_connections(array(
'mysql' => getenv('PHPAR_MYSQL') ?: 'mysql://test:test@127.0.0.1/test',
'pgsql' => getenv('PHPAR_PGSQL') ?: 'pgsql://test:test@127.0.0.1/test',
@@ -46,7 +46,7 @@
if (is_callable('Log::singleton')) // PEAR Log installed
{
- $logger = Log::singleton('file', dirname(__FILE__) . '/../log/query.log','ident',array('mode' => 0664, 'timeFormat' => '%Y-%m-%d %H:%M:%S'));
+ $logger = Log::singleton('file', __DIR__ . '/../log/query.log','ident',array('mode' => 0664, 'timeFormat' => '%Y-%m-%d %H:%M:%S'));
$cfg->set_logging(true);
$cfg->set_logger($logger);

0 comments on commit 6949f8a

Please sign in to comment.