Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrading the SimpleTest library. Adding a mock object and new
tests. Precursor to actual database tests. .
- Loading branch information
1 parent
cc67ba3
commit 03f65fb
Showing
138 changed files
with
24,868 additions
and
21,157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/** | ||
* To run this test from this directory: | ||
* $ php -q functions.php | ||
* sdotest | ||
* OK | ||
* Test cases run: 1/1, Passes: 4, Failures: 0, Exceptions: 0 | ||
*/ | ||
|
||
if (! defined('SIMPLE_TEST')) { | ||
define('SIMPLE_TEST', 'simpletest/'); | ||
} | ||
require_once(SIMPLE_TEST . 'unit_tester.php'); | ||
require_once(SIMPLE_TEST . 'reporter.php'); | ||
require_once('../php/cfg/config.php'); | ||
require_once('../php/lib/memcaching.php'); | ||
require_once('../php/lib/sdo.php'); | ||
require_once('../php/functions.php'); | ||
|
||
# Include the mocks | ||
require_once('./mocks/sdo.php'); | ||
|
||
class FunctionsTest extends UnitTestCase { | ||
|
||
|
||
function testQueryForMirrorsStandalone() { | ||
$sdo_mock = new SDO_Mock(); | ||
$mirrors = queryForMirrors($sdo_mock, 'http', 1, 1); | ||
|
||
|
||
$this->assertTrue(empty($mirrors), 'Mirrors not empty.'); | ||
$this->assertEqual($sdo_mock->requestCount, 2, 'Incorrect number of requests made to database'); | ||
|
||
$sdo_mock->resetCount(); | ||
$sdo_mock->returnJunk = true; | ||
$mirrors = queryForMirrors($sdo_mock, 'http', 1, 1); | ||
|
||
$this->assertFalse(empty($mirrors), 'Mirrors are empty'); | ||
$this->assertEqual($sdo_mock->requestCount, 1, 'Incorrect number of requests made to database'); | ||
} | ||
} | ||
|
||
$test = new FunctionsTest(); | ||
$test->run(new TextReporter()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
class SDO_Mock | ||
{ | ||
public $requestCount = 0; | ||
public $returnJunk = false; | ||
|
||
public function get($query,$args,$type=MYSQL_BOTH,$col_id=null) { | ||
$this->requestCount += 1; | ||
|
||
if($this->returnJunk) { | ||
return array(true); | ||
} else { | ||
return array(); | ||
} | ||
} | ||
|
||
public function resetCount() { | ||
$this->requestCount = 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.0.1beta2 | ||
1.1.0 |
Oops, something went wrong.