Skip to content

Commit

Permalink
Add Criteria::create()
Browse files Browse the repository at this point in the history
  • Loading branch information
asm89 committed Jul 31, 2012
1 parent 8cb70d8 commit 72f487a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
10 changes: 10 additions & 0 deletions lib/Doctrine/Common/Collections/Criteria.php
Expand Up @@ -59,6 +59,16 @@ class Criteria
*/
private $maxResults;

/**
* Creates an instance of the class.
*
* @return Criteria
*/
public static function create()
{
return new static();
}

/**
* Construct new criteria
*
Expand Down
12 changes: 9 additions & 3 deletions tests/Doctrine/Tests/Common/Collections/CriteriaTest.php
Expand Up @@ -6,6 +6,13 @@

class CriteriaTest extends \PHPUnit_Framework_TestCase
{
public function testCreate()
{
$criteria = Criteria::create();

$this->assertInstanceOf("Doctrine\Common\Collections\Criteria", $criteria);
}

public function testConstructor()
{
$expr = new Comparison("field", "=", "value");
Expand All @@ -29,9 +36,8 @@ public function testWhere()

public function testOrderings()
{
$criteria = new Criteria();

$criteria->orderBy(array("foo" => "ASC"));
$criteria = Criteria::create()
->orderBy(array("foo" => "ASC"));

$this->assertEquals(array("foo" => "ASC"), $criteria->getOrderings());
}
Expand Down

0 comments on commit 72f487a

Please sign in to comment.