diff options
Diffstat (limited to 'tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinGeneratorTest.php')
-rw-r--r-- | tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinGeneratorTest.php | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinGeneratorTest.php b/tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinGeneratorTest.php index 8e1ead3aec..0f75716c9c 100644 --- a/tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinGeneratorTest.php +++ b/tests/PHPUnit/Unit/DataAccess/LogQueryBuilder/JoinGeneratorTest.php @@ -255,6 +255,7 @@ class JoinGeneratorTest extends \PHPUnit_Framework_TestCase usort($tables, array($generator, 'sortTablesForJoin')); $expected = array( + 'log_link_visit_action', array ( 'table' => 'log_link_visit_action', 'tableAlias' => 'log_link_visit_action_foo', @@ -265,7 +266,6 @@ class JoinGeneratorTest extends \PHPUnit_Framework_TestCase 'tableAlias' => 'log_action_foo', 'joinOn' => 'log_link_visit_action_foo.idaction_url = log_action_foo.idaction', ), - 'log_link_visit_action', 'log_action', ); @@ -293,6 +293,42 @@ class JoinGeneratorTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $tables); } + public function test_sortTablesForJoin_shouldSortTablesWithCustomJoinRequiringEachOther2() + { + $tables = array( + array( + 'table' => 'log_action', + 'tableAlias' => 'log_action_visit_entry_idaction_name', + 'joinOn' => "log_visit.visit_entry_idaction_name = log_action_visit_entry_idaction_name.idaction" + ), + 'log_link_visit_action', + array( + 'table' => 'log_action', + 'tableAlias' => 'log_action_idaction_event_action', + 'joinOn' => "log_link_visit_action.idaction_event_action = log_action_idaction_event_action.idaction" + ) + ); + + $generator = $this->makeGenerator($tables); + usort($tables, array($generator, 'sortTablesForJoin')); + + $expected = array( + array( + 'table' => 'log_action', + 'tableAlias' => 'log_action_visit_entry_idaction_name', + 'joinOn' => "log_visit.visit_entry_idaction_name = log_action_visit_entry_idaction_name.idaction" + ), + 'log_link_visit_action', + array( + 'table' => 'log_action', + 'tableAlias' => 'log_action_idaction_event_action', + 'joinOn' => "log_link_visit_action.idaction_event_action = log_action_idaction_event_action.idaction" + ) + ); + + $this->assertEquals($expected, $tables); + } + private function generate($tables) { $generator = $this->makeGenerator($tables); |