Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from piotras/ratatoskr
New test and doc update
- Loading branch information
Showing
2 changed files
with
123 additions
and
0 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
69 changes: 69 additions & 0 deletions
69
phpunit/tests/010_Query/SqlQuerySelectDataConstraintGroupTest.php
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,69 @@ | ||
<?php | ||
|
||
class SqlQuerySelectDataConstraintGroupTest extends MidgardTest | ||
{ | ||
protected $select = null; | ||
protected $mgd = null; | ||
|
||
public function setUp() | ||
{ | ||
$this->mgd = midgard_connection::get_instance(); | ||
|
||
if ($this->select === null) { | ||
$this->select = new MidgardSqlQuerySelectData(midgard_connection::get_instance()); | ||
} | ||
} | ||
|
||
public function tearDown() | ||
{ | ||
unset($this->select); | ||
} | ||
|
||
public function testInheritance() | ||
{ | ||
$cg = new MidgardQueryConstraintGroup("AND"); | ||
$this->assertInstanceOf("MidgardQueryConstraintSimple", $cg); | ||
} | ||
|
||
public function testQueryConstraintGroup() | ||
{ | ||
$storage = new MidgardQueryStorage("midgard_snippet"); | ||
$columnA = new MidgardSqlQueryColumn( | ||
new MidgardQueryProperty("name", $storage), | ||
"tbl1", | ||
"a" | ||
); | ||
|
||
$columnB = new MidgardSqlQueryColumn( | ||
new MidgardQueryProperty("code", $storage), | ||
"tbl1", | ||
"b" | ||
); | ||
|
||
$this->select->add_column($columnA); | ||
$this->select->add_column($columnB); | ||
|
||
$cg = new MidgardQueryConstraintGroup("AND"); | ||
|
||
$cg->add_constraint( | ||
new MidgardSqlQueryConstraint( | ||
$columnA, | ||
"<>", | ||
new MidgardQueryValue("") | ||
) | ||
); | ||
|
||
$cg->add_constraint( | ||
new MidgardSqlQueryConstraint( | ||
$columnB, | ||
"<>", | ||
new MidgardQueryValue("") | ||
) | ||
); | ||
|
||
$this->select->set_constraint($cg); | ||
$this->select->execute(); | ||
} | ||
} | ||
|
||
?> |