Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change dirname w/ file constants to use dir constant #124

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Doctrine/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ public static function setPath($path)
public static function getPath()
{
if ( ! self::$_path) {
self::$_path = realpath(dirname(__FILE__) . '/..');
self::$_path = dirname(__DIR__);
}

return self::$_path;
Expand Down Expand Up @@ -1132,7 +1132,7 @@ public static function compile($target = null, $includedDrivers = array())
public static function autoload($className)
{
if (strpos($className, 'sfYaml') === 0) {
require dirname(__FILE__) . '/Parser/sfYaml/' . $className . '.php';
require __DIR__ . '/Parser/sfYaml/' . $className . '.php';

return true;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/Parser/sfYaml/sfYaml.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function load($input)
return $input;
}

require_once dirname(__FILE__).'/sfYamlParser.php';
require_once __DIR__.'/sfYamlParser.php';

$yaml = new sfYamlParser();

Expand Down Expand Up @@ -116,7 +116,7 @@ public static function load($input)
*/
public static function dump($array, $inline = 2)
{
require_once dirname(__FILE__).'/sfYamlDumper.php';
require_once __DIR__.'/sfYamlDumper.php';

$yaml = new sfYamlDumper();

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Parser/sfYaml/sfYamlDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* file that was distributed with this source code.
*/

require_once(dirname(__FILE__).'/sfYamlInline.php');
require_once(__DIR__.'/sfYamlInline.php');

/**
* sfYamlDumper dumps PHP variables to YAML strings.
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Parser/sfYaml/sfYamlInline.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* file that was distributed with this source code.
*/

require_once dirname(__FILE__).'/sfYaml.php';
require_once __DIR__.'/sfYaml.php';

/**
* sfYamlInline implements a YAML parser/dumper for the YAML inline syntax.
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Parser/sfYaml/sfYamlParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* file that was distributed with this source code.
*/

require_once(dirname(__FILE__).'/sfYamlInline.php');
require_once(__DIR__.'/sfYamlInline.php');

if (!defined('PREG_BAD_UTF8_OFFSET_ERROR'))
{
Expand Down
2 changes: 1 addition & 1 deletion tests/CliTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Doctrine_Cli_TestCase extends UnitTestCase
protected function getFixturesPath()
{
if (! isset($this->fixturesPath)) {
$this->fixturesPath = dirname(__FILE__) . '/CliTestCase';
$this->fixturesPath = __DIR__ . '/CliTestCase';
}

return $this->fixturesPath;
Expand Down
4 changes: 2 additions & 2 deletions tests/CliTestCase/cli-default.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* @author Dan Bettles <[email protected]>
*/

require_once(dirname(dirname(dirname(__FILE__))) . '/lib/Doctrine/Core.php');
require_once dirname(__DIR__, 2) . '/lib/Doctrine/Core.php';
spl_autoload_register(array('Doctrine_Core', 'autoload'));

require_once(dirname(__FILE__) . '/TestTask02.php');
require_once(__DIR__ . '/TestTask02.php');

$cli = new Doctrine_Cli();
$cli->run($_SERVER['argv']);
4 changes: 2 additions & 2 deletions tests/CliTestCase/cli-with-custom-tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* @author Dan Bettles <[email protected]>
*/

require_once(dirname(dirname(dirname(__FILE__))) . '/lib/Doctrine/Core.php');
require_once dirname(__DIR__, 2) . '/lib/Doctrine/Core.php';
spl_autoload_register(array('Doctrine_Core', 'autoload'));

$cli = new Doctrine_Cli();

require_once(dirname(__FILE__) . '/TestTask02.php');
require_once(__DIR__ . '/TestTask02.php');

//Either...:
$cli->registerTaskClass('Doctrine_Cli_TestCase_TestTask02');
Expand Down
4 changes: 2 additions & 2 deletions tests/CliTestCase/cli-without-autoregistered-custom-tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* @author Dan Bettles <[email protected]>
*/

require_once(dirname(dirname(dirname(__FILE__))) . '/lib/Doctrine/Core.php');
require_once dirname(__DIR__, 2) . '/lib/Doctrine/Core.php';
spl_autoload_register(array('Doctrine_Core', 'autoload'));

require_once(dirname(__FILE__) . '/TestTask02.php');
require_once(__DIR__ . '/TestTask02.php');

$cli = new Doctrine_Cli(array('autoregister_custom_tasks' => false));
$cli->run($_SERVER['argv']);
20 changes: 10 additions & 10 deletions tests/DoctrineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
* @version $Revision$
*/

require_once dirname(__FILE__) . '/DoctrineTest/UnitTestCase.php';
require_once dirname(__FILE__) . '/DoctrineTest/GroupTest.php';
require_once dirname(__FILE__) . '/DoctrineTest/Doctrine_UnitTestCase.php';
require_once dirname(__FILE__) . '/DoctrineTest/Reporter.php';
require_once __DIR__ . '/DoctrineTest/UnitTestCase.php';
require_once __DIR__ . '/DoctrineTest/GroupTest.php';
require_once __DIR__ . '/DoctrineTest/Doctrine_UnitTestCase.php';
require_once __DIR__ . '/DoctrineTest/Reporter.php';

class DoctrineTest
{
Expand Down Expand Up @@ -75,13 +75,13 @@ public function run()
{
$testGroup = $this->testGroup;
if (PHP_SAPI === 'cli') {
require_once(dirname(__FILE__) . '/DoctrineTest/Reporter/Cli.php');
require_once(__DIR__ . '/DoctrineTest/Reporter/Cli.php');
$reporter = new DoctrineTest_Reporter_Cli();
$argv = $_SERVER['argv'];
array_shift($argv);
$options = $this->parseOptions($argv);
} else {
require_once(dirname(__FILE__) . '/DoctrineTest/Reporter/Html.php');
require_once(__DIR__ . '/DoctrineTest/Reporter/Html.php');
$options = $_GET;
if (isset($options['filter'])) {
if ( ! is_array($options['filter'])) {
Expand Down Expand Up @@ -148,7 +148,7 @@ public function run()
* somebody could give it a try. Just replace this block of code
* with the one below
*
define('PHPCOVERAGE_HOME', dirname(dirname(__FILE__)) . '/vendor/spikephpcoverage');
define('PHPCOVERAGE_HOME', dirname(__DIR__) . '/vendor/spikephpcoverage');
require_once PHPCOVERAGE_HOME . '/CoverageRecorder.php';
require_once PHPCOVERAGE_HOME . '/reporter/HtmlCoverageReporter.php';

Expand All @@ -170,8 +170,8 @@ public function run()
$ret = $testGroup->run($reporter, $filter);
$result['coverage'] = xdebug_get_code_coverage();
xdebug_stop_code_coverage();
file_put_contents(dirname(__FILE__) . '/coverage/coverage.txt', serialize($result));
require_once dirname(__FILE__) . '/DoctrineTest/Coverage.php';
file_put_contents(__DIR__ . '/coverage/coverage.txt', serialize($result));
require_once __DIR__ . '/DoctrineTest/Coverage.php';
$coverageGeneration = new DoctrineTest_Coverage();
$coverageGeneration->generateReport();
return $ret;
Expand Down Expand Up @@ -203,7 +203,7 @@ public function run()
*/
public function requireModels()
{
$models = new DirectoryIterator(dirname(__FILE__) . '/models/');
$models = new DirectoryIterator(__DIR__ . '/models/');

foreach($models as $key => $file) {
if ($file->isFile() && ! $file->isDot()) {
Expand Down
2 changes: 1 addition & 1 deletion tests/DoctrineTest/UnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function getPassCount()

public function getPassesAndFailsCachePath()
{
$dir = dirname(__FILE__) . '/doctrine_tests';
$dir = __DIR__ . '/doctrine_tests';
if ( ! is_dir($dir)) {
mkdir($dir, 0777, true);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Export/PgsqlTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function testCreateTableSupportsMultiplePks()
public function testExportSql()
{
$sql = $this->export->exportClassesSql(array("FooRecord", "FooReferenceRecord", "FooLocallyOwned", "FooForeignlyOwned", "FooForeignlyOwnedWithPK", "FooBarRecord", "BarRecord"));
//dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files');
//__DIR__ . DIRECTORY_SEPARATOR . '_files');

$this->assertEqual($sql, array ( 0 => 'CREATE TABLE foo_reference (foo1 BIGINT, foo2 BIGINT, PRIMARY KEY(foo1, foo2))',
1 => 'CREATE TABLE foo_locally_owned (id BIGSERIAL, name VARCHAR(200), PRIMARY KEY(id))',
Expand Down Expand Up @@ -175,4 +175,4 @@ public function testAlterTableSqlIdentifierQuoting()
1 => 'ALTER TABLE "mytable" DROP "oldfield"'
));
}
}
}
2 changes: 1 addition & 1 deletion tests/Export/RecordTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function testExportSupportsForeignKeysForManyToManyRelations()
public function testExportModelFromDirectory()
{

Doctrine_Core::createTablesFromModels(dirname(__FILE__) . DIRECTORY_SEPARATOR .'..' . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . 'export');
Doctrine_Core::createTablesFromModels(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . 'export');
$this->assertEqual($this->adapter->pop(), 'COMMIT');
$this->assertEqual($this->adapter->pop(), 'ALTER TABLE cms__category_languages ADD CONSTRAINT cms__category_languages_category_id_cms__category_id FOREIGN KEY (category_id) REFERENCES cms__category(id) ON DELETE CASCADE');
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE cms__category_languages (id BIGINT AUTO_INCREMENT, name TEXT, category_id BIGINT, language_id BIGINT, INDEX index_category_idx (category_id), INDEX index_language_idx (language_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB');
Expand Down
2 changes: 1 addition & 1 deletion tests/Export/SchemaTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Doctrine_Export_Schema_TestCase extends Doctrine_UnitTestCase
public function testYmlExport()
{
$export = new Doctrine_Export_Schema();
$export->exportSchema('schema-export.yml', 'yml', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'models', $this->tables);
$export->exportSchema('schema-export.yml', 'yml', dirname(__DIR__) . DIRECTORY_SEPARATOR . 'models', $this->tables);
unlink('schema-export.yml');
}
}
2 changes: 1 addition & 1 deletion tests/ExtensionTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Doctrine_Extension_TestCase extends Doctrine_UnitTestCase
{
public function prepareTables()
{
Doctrine_Core::setExtensionsPath(dirname(__FILE__).'/Extension');
Doctrine_Core::setExtensionsPath(__DIR__.'/Extension');
spl_autoload_register(array('Doctrine_Core', 'extensionsAutoload'));

Doctrine_Manager::getInstance()
Expand Down
4 changes: 2 additions & 2 deletions tests/Import/BuilderTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Doctrine_Import_Builder_TestCase extends Doctrine_UnitTestCase
{
public function testInheritanceGeneration()
{
$path = dirname(__FILE__) . '/import_builder_test';
$path = __DIR__ . '/import_builder_test';

$import = new Doctrine_Import_Schema();
$import->setOption('generateTableClasses', true);
Expand Down Expand Up @@ -122,4 +122,4 @@ public function testBaseTableClass()
$class = $builder->buildTableClassDefinition('MyTestTable', array('className' => 'MyTest'));
$this->assertTrue(strpos($class, 'class MyTestTable extends MyBaseTable'));
}
}
}
4 changes: 2 additions & 2 deletions tests/Import/PluginHierarchyTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function testImportOfHieriarchyOfPluginGeneration()
END;

file_put_contents('wiki.yml', $yml);
$path = dirname(__FILE__) . '/tmp/import_builder_test';
$path = __DIR__ . '/tmp/import_builder_test';

$import = new Doctrine_Import_Schema();
$import->setOption('generateTableClasses', true);
Expand Down Expand Up @@ -83,4 +83,4 @@ public function testImportOfHieriarchyOfPluginGeneration()
Doctrine_Lib::removeDirectories($path);
unlink('wiki.yml');
}
}
}
4 changes: 2 additions & 2 deletions tests/Import/SchemaTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Doctrine_Import_Schema_TestCase extends Doctrine_UnitTestCase

public function testYmlImport()
{
$path = dirname(__FILE__) . '/import_builder_test';
$path = __DIR__ . '/import_builder_test';

$import = new Doctrine_Import_Schema();
$import->importSchema('schema.yml', 'yml', $path);
Expand Down Expand Up @@ -110,4 +110,4 @@ protected function _verifyMultiDirectionalRelationship($class, $relationAlias, $
return false;
}
}
}
}
8 changes: 4 additions & 4 deletions tests/Migration/DiffTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class Doctrine_Migration_Diff_TestCase extends Doctrine_UnitTestCase
{
public function testTest()
{
$from = dirname(__FILE__) . '/Diff/schema/from.yml';
$to = dirname(__FILE__) . '/Diff/schema/to.yml';
$migrationsPath = dirname(__FILE__) . '/Diff/migrations';
$from = __DIR__ . '/Diff/schema/from.yml';
$to = __DIR__ . '/Diff/schema/to.yml';
$migrationsPath = __DIR__ . '/Diff/migrations';
Doctrine_Lib::makeDirectories($migrationsPath);

$diff = new Doctrine_Migration_Diff($from, $to, $migrationsPath);
Expand Down Expand Up @@ -76,4 +76,4 @@ public function testTest()

Doctrine_Lib::removeDirectories($migrationsPath);
}
}
}
2 changes: 1 addition & 1 deletion tests/Search/FileTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testSearchFileAutoCreatesFileTable()

public function testIndexDirectoryIndexesAllFiles()
{
$this->_search->indexDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files');
$this->_search->indexDirectory(__DIR__ . DIRECTORY_SEPARATOR . '_files');

$resultSet = $this->_search->search('dbms');

Expand Down
2 changes: 1 addition & 1 deletion tests/Search/IndexerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testIndexexCanRecursivelyIndexDirectories()

$indexer = new Doctrine_Search_Indexer();

$indexer->indexDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files');
$indexer->indexDirectory(__DIR__ . DIRECTORY_SEPARATOR . '_files');
}

public function testIndexerAddsFiles()
Expand Down
2 changes: 1 addition & 1 deletion tests/TaskTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function testSettasknameSetsTheNameOfTheTask()
*/
protected function loadPhpFixture($basename)
{
require_once(dirname(__FILE__) . '/TaskTestCase/' . $basename);
require_once(__DIR__ . '/TaskTestCase/' . $basename);
}

public function testSettasknameThrowsAnExceptionIfTheTaskNameIsInvalid()
Expand Down
4 changes: 2 additions & 2 deletions tests/Ticket/1527TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public function testTest()
$schema = $import->buildSchema($yml, 'yml');
$this->assertEqual($schema['Ticket_1527_User']['columns']['username']['extra']['test'], '123');

$path = dirname(__FILE__) . '/../tmp';
$path = dirname(__DIR__) . '/tmp';
$import->importSchema($yml, 'yml', $path);

require_once($path . '/generated/BaseTicket_1527_User.php');
require_once($path . '/Ticket_1527_User.php');
$username = Doctrine_Core::getTable('Ticket_1527_User')->getDefinitionOf('username');
$this->assertEqual($username['extra']['test'], '123');
}
}
}
34 changes: 17 additions & 17 deletions tests/Ticket/1727TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,36 @@ class Doctrine_Ticket_1727_TestCase extends Doctrine_UnitTestCase
{
public function testTest()
{
$models1 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models1', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$models2 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models1', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$models1 = Doctrine_Core::loadModels(__DIR__ . '/1727/models1', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$models2 = Doctrine_Core::loadModels(__DIR__ . '/1727/models1', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$this->assertEqual($models1, $models2);

$models1 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models1');
$models2 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models1');
$models1 = Doctrine_Core::loadModels(__DIR__ . '/1727/models1');
$models2 = Doctrine_Core::loadModels(__DIR__ . '/1727/models1');
$this->assertEqual($models1, $models2);

$models1 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models1', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$models2 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models1', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$models1 = Doctrine_Core::loadModels(__DIR__ . '/1727/models1', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$models2 = Doctrine_Core::loadModels(__DIR__ . '/1727/models1', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$this->assertEqual($models1, $models2);

$models1 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models2', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$models2 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models2', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$models1 = Doctrine_Core::loadModels(__DIR__ . '/1727/models2', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$models2 = Doctrine_Core::loadModels(__DIR__ . '/1727/models2', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$this->assertEqual($models1, $models2);

$models1 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models2');
$models2 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models2');
$models1 = Doctrine_Core::loadModels(__DIR__ . '/1727/models2');
$models2 = Doctrine_Core::loadModels(__DIR__ . '/1727/models2');
$this->assertEqual($models1, $models2);

$models1 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models2', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$models2 = Doctrine_Core::loadModels(dirname(__FILE__) . '/1727/models2', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$models1 = Doctrine_Core::loadModels(__DIR__ . '/1727/models2', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$models2 = Doctrine_Core::loadModels(__DIR__ . '/1727/models2', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$this->assertEqual($models1, $models2);

$models1 = Doctrine_Core::loadModels(array(dirname(__FILE__) . '/1727/models1', dirname(__FILE__) . '/1727/models2'));
$models2 = Doctrine_Core::loadModels(array(dirname(__FILE__) . '/1727/models1', dirname(__FILE__) . '/1727/models2'));
$models1 = Doctrine_Core::loadModels(array(__DIR__ . '/1727/models1', __DIR__ . '/1727/models2'));
$models2 = Doctrine_Core::loadModels(array(__DIR__ . '/1727/models1', __DIR__ . '/1727/models2'));
$this->assertEqual($models1, $models2);

$models1 = Doctrine_Core::loadModels(array(dirname(__FILE__) . '/1727/models1', dirname(__FILE__) . '/1727/models2'), Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$models2 = Doctrine_Core::loadModels(array(dirname(__FILE__) . '/1727/models1', dirname(__FILE__) . '/1727/models2'), Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$models1 = Doctrine_Core::loadModels(array(__DIR__ . '/1727/models1', __DIR__ . '/1727/models2'), Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$models2 = Doctrine_Core::loadModels(array(__DIR__ . '/1727/models1', __DIR__ . '/1727/models2'), Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$this->assertEqual($models1, $models2);
}
}
}
Loading
Loading