Added a test case to track an ugly bug.
This commit is contained in:
parent
4eb1060b13
commit
05a23f6a30
110
tests/CustomResultSetOrderTestCase.php
Normal file
110
tests/CustomResultSetOrderTestCase.php
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
<?PHP
|
||||||
|
class Doctrine_CustomResultSetOrderTestCase extends Doctrine_UnitTestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares the data under test.
|
||||||
|
*
|
||||||
|
* 1st category: 3 Boards
|
||||||
|
* 2nd category: 1 Board
|
||||||
|
* 3rd category: 0 boards
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function prepareData() {
|
||||||
|
$cat1 = new CategoryWithPosition();
|
||||||
|
$cat1->position = 0;
|
||||||
|
$cat1->name = "First";
|
||||||
|
|
||||||
|
$cat2 = new CategoryWithPosition();
|
||||||
|
$cat2->position = 0; // same 'priority' as the first
|
||||||
|
$cat2->name = "Second";
|
||||||
|
|
||||||
|
$cat3 = new CategoryWithPosition();
|
||||||
|
$cat3->position = 1;
|
||||||
|
$cat3->name = "Third";
|
||||||
|
|
||||||
|
$board1 = new BoardWithPosition();
|
||||||
|
$board1->position = 0;
|
||||||
|
|
||||||
|
$board2 = new BoardWithPosition();
|
||||||
|
$board2->position = 1;
|
||||||
|
|
||||||
|
$board3 = new BoardWithPosition();
|
||||||
|
$board3->position = 2;
|
||||||
|
|
||||||
|
// The first category gets 3 boards!
|
||||||
|
$cat1->Boards[0] = $board1;
|
||||||
|
$cat1->Boards[1] = $board2;
|
||||||
|
$cat1->Boards[2] = $board3;
|
||||||
|
|
||||||
|
$board4 = new BoardWithPosition();
|
||||||
|
$board4->position = 0;
|
||||||
|
|
||||||
|
// The second category gets 1 board!
|
||||||
|
$cat2->Boards[0] = $board4;
|
||||||
|
|
||||||
|
$this->connection->flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares the tables.
|
||||||
|
*/
|
||||||
|
public function prepareTables() {
|
||||||
|
$this->tables[] = "CategoryWithPosition";
|
||||||
|
$this->tables[] = "BoardWithPosition";
|
||||||
|
parent::prepareTables();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the boards are correctly assigned to the categories.
|
||||||
|
*
|
||||||
|
* The 'evil' result set that confuses the object population is displayed below.
|
||||||
|
*
|
||||||
|
* catId | catPos | catName | boardPos | board.category_id
|
||||||
|
* 1 | 0 | First | 0 | 1
|
||||||
|
* 2 | 0 | Second | 0 | 2 <-- The split that confuses the object population
|
||||||
|
* 1 | 0 | First | 1 | 1
|
||||||
|
* 1 | 0 | First | 2 | 1
|
||||||
|
* 3 | 2 | Third | NULL
|
||||||
|
*/
|
||||||
|
public function testQueryWithOrdering() {
|
||||||
|
$categories = $this->connection->query("FROM CategoryWithPosition.Boards
|
||||||
|
ORDER BY CategoryWithPosition.position ASC, CategoryWithPosition.Boards.position ASC");
|
||||||
|
|
||||||
|
// Check each category
|
||||||
|
foreach ($categories as $category) {
|
||||||
|
|
||||||
|
switch ($category->name) {
|
||||||
|
case "First":
|
||||||
|
// The first category should have 3 boards, right?
|
||||||
|
// It has only 1! The other two slipped to the 2nd category!
|
||||||
|
$this->assertEqual(3, $category->Boards->count());
|
||||||
|
break;
|
||||||
|
case "Second":
|
||||||
|
// The second category should have 1 board, but it got 3 now
|
||||||
|
$this->assertEqual(1, $category->Boards->count());
|
||||||
|
break;
|
||||||
|
case "Third":
|
||||||
|
// The third has no boards as expected.
|
||||||
|
$this->assertEqual(0, $category->Boards->count());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
1068
tests/classes.php
1068
tests/classes.php
File diff suppressed because it is too large
Load Diff
425
tests/run.php
425
tests/run.php
@ -1,211 +1,214 @@
|
|||||||
<?php
|
<?php
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|
||||||
require_once("ConfigurableTestCase.php");
|
require_once("ConfigurableTestCase.php");
|
||||||
require_once("ManagerTestCase.php");
|
require_once("ManagerTestCase.php");
|
||||||
require_once("ConnectionTestCase.php");
|
require_once("ConnectionTestCase.php");
|
||||||
require_once("ConnectionTransactionTestCase.php");
|
require_once("ConnectionTransactionTestCase.php");
|
||||||
require_once("TableTestCase.php");
|
require_once("TableTestCase.php");
|
||||||
require_once("EventListenerTestCase.php");
|
require_once("EventListenerTestCase.php");
|
||||||
require_once("BatchIteratorTestCase.php");
|
require_once("BatchIteratorTestCase.php");
|
||||||
require_once("CacheFileTestCase.php");
|
require_once("CacheFileTestCase.php");
|
||||||
require_once("RecordTestCase.php");
|
require_once("RecordTestCase.php");
|
||||||
require_once("AccessTestCase.php");
|
require_once("AccessTestCase.php");
|
||||||
require_once("ValidatorTestCase.php");
|
require_once("ValidatorTestCase.php");
|
||||||
require_once("CollectionTestCase.php");
|
require_once("CollectionTestCase.php");
|
||||||
require_once("PessimisticLockingTestCase.php");
|
require_once("PessimisticLockingTestCase.php");
|
||||||
require_once("EventListenerChainTestCase.php");
|
require_once("EventListenerChainTestCase.php");
|
||||||
require_once("CacheSqliteTestCase.php");
|
require_once("CacheSqliteTestCase.php");
|
||||||
require_once("CollectionOffsetTestCase.php");
|
require_once("CollectionOffsetTestCase.php");
|
||||||
require_once("QueryTestCase.php");
|
require_once("QueryTestCase.php");
|
||||||
require_once("CacheQuerySqliteTestCase.php");
|
require_once("CacheQuerySqliteTestCase.php");
|
||||||
require_once("ViewTestCase.php");
|
require_once("ViewTestCase.php");
|
||||||
require_once("RawSqlTestCase.php");
|
require_once("RawSqlTestCase.php");
|
||||||
require_once("CustomPrimaryKeyTestCase.php");
|
require_once("CustomPrimaryKeyTestCase.php");
|
||||||
require_once("FilterTestCase.php");
|
require_once("FilterTestCase.php");
|
||||||
require_once("ValueHolderTestCase.php");
|
require_once("ValueHolderTestCase.php");
|
||||||
require_once("QueryLimitTestCase.php");
|
require_once("QueryLimitTestCase.php");
|
||||||
require_once("QueryMultiJoinTestCase.php");
|
require_once("QueryMultiJoinTestCase.php");
|
||||||
require_once("QueryReferenceModelTestCase.php");
|
require_once("QueryReferenceModelTestCase.php");
|
||||||
require_once("DBTestCase.php");
|
require_once("DBTestCase.php");
|
||||||
require_once("SchemaTestCase.php");
|
require_once("SchemaTestCase.php");
|
||||||
require_once("ImportTestCase.php");
|
require_once("ImportTestCase.php");
|
||||||
require_once("BooleanTestCase.php");
|
require_once("BooleanTestCase.php");
|
||||||
require_once("EnumTestCase.php");
|
require_once("EnumTestCase.php");
|
||||||
require_once("RelationAccessTestCase.php");
|
require_once("RelationAccessTestCase.php");
|
||||||
require_once("RelationTestCase.php");
|
require_once("RelationTestCase.php");
|
||||||
require_once("DataDictSqliteTestCase.php");
|
require_once("DataDictSqliteTestCase.php");
|
||||||
|
require_once("CustomResultSetOrderTestCase.php");
|
||||||
error_reporting(E_ALL);
|
|
||||||
|
error_reporting(E_ALL);
|
||||||
$test = new GroupTest("Doctrine Framework Unit Tests");
|
|
||||||
|
$test = new GroupTest("Doctrine Framework Unit Tests");
|
||||||
$test->addTestCase(new Doctrine_Relation_TestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_Relation_TestCase());
|
||||||
$test->addTestCase(new Doctrine_Query_MultiJoin_TestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_Query_MultiJoin_TestCase());
|
||||||
$test->addTestCase(new Doctrine_EventListenerTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_EventListenerTestCase());
|
||||||
$test->addTestCase(new Doctrine_RecordTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_RecordTestCase());
|
||||||
$test->addTestCase(new Doctrine_Connection_Transaction_TestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_Connection_Transaction_TestCase());
|
||||||
$test->addTestCase(new Doctrine_ConnectionTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_ConnectionTestCase());
|
||||||
$test->addTestCase(new Doctrine_DB_TestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_DB_TestCase());
|
||||||
$test->addTestCase(new Doctrine_AccessTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_AccessTestCase());
|
||||||
$test->addTestCase(new Doctrine_TableTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_TableTestCase());
|
||||||
$test->addTestCase(new Doctrine_ManagerTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_ManagerTestCase());
|
||||||
$test->addTestCase(new Doctrine_BatchIteratorTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_BatchIteratorTestCase());
|
||||||
$test->addTestCase(new Doctrine_ConfigurableTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_ConfigurableTestCase());
|
||||||
$test->addTestCase(new Doctrine_ValidatorTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_ValidatorTestCase());
|
||||||
$test->addTestCase(new Doctrine_Collection_OffsetTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_Collection_OffsetTestCase());
|
||||||
$test->addTestCase(new Doctrine_PessimisticLockingTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_PessimisticLockingTestCase());
|
||||||
$test->addTestCase(new Doctrine_ViewTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_ViewTestCase());
|
||||||
$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
|
||||||
$test->addTestCase(new Doctrine_CustomPrimaryKeyTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_CustomPrimaryKeyTestCase());
|
||||||
$test->addTestCase(new Doctrine_Filter_TestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_Filter_TestCase());
|
||||||
$test->addTestCase(new Doctrine_ValueHolder_TestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_ValueHolder_TestCase());
|
||||||
$test->addTestCase(new Doctrine_RawSql_TestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_RawSql_TestCase());
|
||||||
$test->addTestCase(new Doctrine_Query_Limit_TestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_Query_Limit_TestCase());
|
||||||
//$test->addTestCase(new Doctrine_SchemaTestCase());
|
|
||||||
|
//$test->addTestCase(new Doctrine_SchemaTestCase());
|
||||||
//$test->addTestCase(new Doctrine_ImportTestCase());
|
|
||||||
|
//$test->addTestCase(new Doctrine_ImportTestCase());
|
||||||
$test->addTestCase(new Doctrine_CollectionTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_CollectionTestCase());
|
||||||
$test->addTestCase(new Doctrine_Query_ReferenceModel_TestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_Query_ReferenceModel_TestCase());
|
||||||
$test->addTestCase(new Doctrine_EnumTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_EnumTestCase());
|
||||||
$test->addTestCase(new Doctrine_RelationAccessTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_RelationAccessTestCase());
|
||||||
$test->addTestCase(new Doctrine_DataDict_Sqlite_TestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_DataDict_Sqlite_TestCase());
|
||||||
$test->addTestCase(new Doctrine_BooleanTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_BooleanTestCase());
|
||||||
$test->addTestCase(new Doctrine_QueryTestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_QueryTestCase());
|
||||||
$test->addTestCase(new Doctrine_EventListener_Chain_TestCase());
|
|
||||||
|
$test->addTestCase(new Doctrine_EventListener_Chain_TestCase());
|
||||||
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
|
|
||||||
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
|
$test->addTestCase(new Doctrine_CustomResultSetOrderTestCase());
|
||||||
|
|
||||||
class MyReporter extends HtmlReporter {
|
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
|
||||||
public function paintHeader() {}
|
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
|
||||||
public function paintFooter()
|
|
||||||
{
|
class MyReporter extends HtmlReporter {
|
||||||
$colour = ($this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green");
|
public function paintHeader() {}
|
||||||
print "<div style=\"";
|
public function paintFooter()
|
||||||
print "padding: 8px; margin-top: 1em; background-color: $colour; color: white;";
|
{
|
||||||
print "\">";
|
$colour = ($this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green");
|
||||||
print $this->getTestCaseProgress() . "/" . $this->getTestCaseCount();
|
print "<div style=\"";
|
||||||
print " test cases complete:\n";
|
print "padding: 8px; margin-top: 1em; background-color: $colour; color: white;";
|
||||||
print "<strong>" . $this->getPassCount() . "</strong> passes, ";
|
print "\">";
|
||||||
print "<strong>" . $this->getFailCount() . "</strong> fails and ";
|
print $this->getTestCaseProgress() . "/" . $this->getTestCaseCount();
|
||||||
print "<strong>" . $this->getExceptionCount() . "</strong> exceptions.";
|
print " test cases complete:\n";
|
||||||
print "</div>\n";
|
print "<strong>" . $this->getPassCount() . "</strong> passes, ";
|
||||||
}
|
print "<strong>" . $this->getFailCount() . "</strong> fails and ";
|
||||||
}
|
print "<strong>" . $this->getExceptionCount() . "</strong> exceptions.";
|
||||||
|
print "</div>\n";
|
||||||
if (TextReporter::inCli()) {
|
}
|
||||||
if ($argc == 4)
|
}
|
||||||
{
|
|
||||||
$dsn = $argv[1];
|
if (TextReporter::inCli()) {
|
||||||
$username = $argv[2];
|
if ($argc == 4)
|
||||||
$password = $argv[3];
|
{
|
||||||
}
|
$dsn = $argv[1];
|
||||||
exit ($test->run(new TextReporter()) ? 0 : 1);
|
$username = $argv[2];
|
||||||
} else {
|
$password = $argv[3];
|
||||||
if (isset($_POST))
|
}
|
||||||
{
|
exit ($test->run(new TextReporter()) ? 0 : 1);
|
||||||
$dsn = isset($_POST['dsn'])?$_POST['dsn']:null;
|
} else {
|
||||||
$username = isset($_POST['username'])?$_POST['username']:null;
|
if (isset($_POST))
|
||||||
$password = isset($_POST['password'])?$_POST['password']:null;
|
{
|
||||||
}
|
$dsn = isset($_POST['dsn'])?$_POST['dsn']:null;
|
||||||
$test->run(new MyReporter());
|
$username = isset($_POST['username'])?$_POST['username']:null;
|
||||||
$output = ob_get_clean();
|
$password = isset($_POST['password'])?$_POST['password']:null;
|
||||||
}
|
}
|
||||||
/**
|
$test->run(new MyReporter());
|
||||||
$cache = Doctrine_Manager::getInstance()->getCurrentConnection()->getCacheHandler();
|
$output = ob_get_clean();
|
||||||
if(isset($cache)) {
|
}
|
||||||
$a = $cache->getQueries();
|
/**
|
||||||
print "Executed cache queries: ".count($a)."\n";
|
$cache = Doctrine_Manager::getInstance()->getCurrentConnection()->getCacheHandler();
|
||||||
|
if(isset($cache)) {
|
||||||
foreach($a as $query) {
|
$a = $cache->getQueries();
|
||||||
print $query."\n";
|
print "Executed cache queries: ".count($a)."\n";
|
||||||
}
|
|
||||||
|
foreach($a as $query) {
|
||||||
}
|
print $query."\n";
|
||||||
*/
|
}
|
||||||
?>
|
|
||||||
<html>
|
}
|
||||||
<head>
|
*/
|
||||||
|
?>
|
||||||
<title>Doctrine Unit Tests</title>
|
<html>
|
||||||
<style>
|
<head>
|
||||||
.fail { color: red; } pre { background-color: lightgray; }
|
|
||||||
</style>
|
<title>Doctrine Unit Tests</title>
|
||||||
</head>
|
<style>
|
||||||
|
.fail { color: red; } pre { background-color: lightgray; }
|
||||||
<body>
|
</style>
|
||||||
|
</head>
|
||||||
<h1>Doctrine Unit Tests</h1>
|
|
||||||
<h3>DSN Settings</h3>
|
<body>
|
||||||
<form method="post">
|
|
||||||
<table>
|
<h1>Doctrine Unit Tests</h1>
|
||||||
<tr>
|
<h3>DSN Settings</h3>
|
||||||
<th>DSN</th>
|
<form method="post">
|
||||||
<td><input type="text" name="dsn" /></td>
|
<table>
|
||||||
</tr>
|
<tr>
|
||||||
<tr>
|
<th>DSN</th>
|
||||||
<th>Username</th>
|
<td><input type="text" name="dsn" /></td>
|
||||||
<td><input type="text" name="username" /></td>
|
</tr>
|
||||||
</tr>
|
<tr>
|
||||||
<tr>
|
<th>Username</th>
|
||||||
<th>Password</th>
|
<td><input type="text" name="username" /></td>
|
||||||
<td><input type="text" name="password" /></td>
|
</tr>
|
||||||
</tr>
|
<tr>
|
||||||
<tr>
|
<th>Password</th>
|
||||||
<td> </td>
|
<td><input type="text" name="password" /></td>
|
||||||
<td><input type="submit" name="submit" /></td>
|
</tr>
|
||||||
</tr>
|
<tr>
|
||||||
</table>
|
<td> </td>
|
||||||
</form>
|
<td><input type="submit" name="submit" /></td>
|
||||||
<h3>Tests</h3>
|
</tr>
|
||||||
<pre>
|
</table>
|
||||||
<?php echo $output; ?>
|
</form>
|
||||||
</pre>
|
<h3>Tests</h3>
|
||||||
<h3>Queries</h3>
|
<pre>
|
||||||
<pre>
|
<?php echo $output; ?>
|
||||||
<?php
|
</pre>
|
||||||
$dbh = Doctrine_Manager::getInstance()->getCurrentConnection()->getDBH();
|
<h3>Queries</h3>
|
||||||
$a = $dbh->getQueries();
|
<pre>
|
||||||
|
<?php
|
||||||
print "Executed queries: ".count($a)."\n";
|
$dbh = Doctrine_Manager::getInstance()->getCurrentConnection()->getDBH();
|
||||||
|
$a = $dbh->getQueries();
|
||||||
foreach($a as $query) {
|
|
||||||
print $query."\n";
|
print "Executed queries: ".count($a)."\n";
|
||||||
}
|
|
||||||
?>
|
foreach($a as $query) {
|
||||||
</pre>
|
print $query."\n";
|
||||||
</body>
|
}
|
||||||
</html>
|
?>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user