Skip to content

Commit

Permalink
Removed Scisr_Db and refactored last tests that used file-based database
Browse files Browse the repository at this point in the history
  • Loading branch information
giorgiosironi committed Jul 27, 2010
1 parent 14f2906 commit 0982dab
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 46 deletions.
40 changes: 0 additions & 40 deletions Db.php

This file was deleted.

3 changes: 2 additions & 1 deletion Scisr.php
Expand Up @@ -109,7 +109,8 @@ public function setOutput($output)
public static function createScisr($className = 'Scisr', $db = null)
{
if ($db === null) {
$db = Scisr_Db::getDb();
$db_path = dirname(__FILE__) . '/cache.db';
$db = new PDO("sqlite:$db_path", null, null, array(PDO::ATTR_PERSISTENT => true));
}
$dbFiles = new Scisr_Db_Files($db);
$dbFiles->init();
Expand Down
7 changes: 3 additions & 4 deletions tests/AbstractVariableTypeTest.php
Expand Up @@ -55,7 +55,7 @@ public function testGetEndOfVar($code, $startContent, $endContent, $endPtrOffset
}
$expectedEndPtr += $endPtrOffset;
// Fire up the tester
$tester = new AbstractVariableTypeTester();
$tester = new AbstractVariableTypeTester($this->getDb());
$endPtr = $tester->exposeGetEndOfVar($startPtr, $tokens);

$this->assertEquals($expectedEndPtr, $endPtr);
Expand All @@ -75,7 +75,7 @@ public function testGetStartOfVar($code, $startContent, $endContent, $endPtrOffs
}
$endPtr += $endPtrOffset;
// Fire up the tester
$tester = new AbstractVariableTypeTester();
$tester = new AbstractVariableTypeTester($this->getDb());
$startPtr = $tester->exposeGetStartOfVar($endPtr, $tokens);

$this->assertEquals($startContent, $tokens[$startPtr]['content']);
Expand Down Expand Up @@ -138,9 +138,8 @@ public function variableProvider() {
*/
class AbstractVariableTypeTester extends Scisr_Operations_VariableTypes
{
public function __construct()
public function __construct($db)
{
$db = Scisr_Db::getDb();
parent::__construct(new Scisr_Db_Classes($db), new Scisr_Db_FileIncludes($db), new Scisr_Db_VariableTypes($db));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Db/FileIncludesTest.php
Expand Up @@ -3,7 +3,7 @@

class Scisr_Db_FileIncludesTest extends Scisr_TestCase {
public function testIncludeFileRepeatedly() {
$dbFileIncludes = new Scisr_Db_FileIncludes(Scisr_Db::getDb());
$dbFileIncludes = new Scisr_Db_FileIncludes($this->getDb());
$dbFileIncludes->init();
$dbFileIncludes->registerFileInclude('/x/y/myfile.php', '/x/z/otherfile.php');
$dbFileIncludes->registerFileInclude('/x/y/myfile.php', '/x/z/otherfile.php');
Expand Down

0 comments on commit 0982dab

Please sign in to comment.