Skip to content

Commit

Permalink
collection: fixed operator constants [closes #145]
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed Dec 14, 2015
1 parent 8f47862 commit 50276eb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Collection/Helpers/ConditionParserHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class ConditionParserHelper
const OPERATOR_EQUAL = '=';
const OPERATOR_NOT_EQUAL = '!=';
const OPERATOR_GREATER = '>';
const OPERATOR_EQUAL_OR_GREATER = '=>';
const OPERATOR_EQUAL_OR_GREATER = '>=';
const OPERATOR_SMALLER = '<';
const OPERATOR_EQUAL_OR_SMALLER = '=<';
const OPERATOR_EQUAL_OR_SMALLER = '<=';


public static function parseCondition($condition)
Expand Down
17 changes: 16 additions & 1 deletion tests/cases/unit/Collection/ArrayCollectionTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,22 @@ class ArrayCollectionTest extends TestCase
}


public function testOperators()
{
$books = new ArrayCollection([
$this->e(Book::class, ['title' => '1']),
$this->e(Book::class, ['title' => '2']),
$this->e(Book::class, ['title' => '3']),
$this->e(Book::class, ['title' => '4']),
], $this->orm->books);

Assert::equal(2, $books->findBy(['title>=' => 3])->count());
Assert::equal(3, $books->findBy(['title<=' => 3])->count());
Assert::equal(1, $books->findBy(['title>' => 3])->count());
Assert::equal(2, $books->findBy(['title<' => 3])->count());
}


private function createCollection()
{
$authors = [
Expand All @@ -159,7 +175,6 @@ class ArrayCollectionTest extends TestCase

return [new ArrayCollection($authors, $this->orm->authors), $authors, $books];
}

}


Expand Down

0 comments on commit 50276eb

Please sign in to comment.