Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

git-svn-id: http://mongodb-morph.googlecode.com/svn/trunk@120 406649b…

…4-5d4b-11de-8abc-d1c337b90d21
  • Loading branch information...
commit 30132df0ad0cc85cb18a95301736b44d23cb8cd8 1 parent 7798faf
XirisR authored
View
4 mongodb-morph/integration-tests/TestComposeMany.php
@@ -2,6 +2,7 @@
/**
* @author Jonathan Moss <xirisr@gmail.com>
* @copyright 2010 Jonathan Moss
+ * @package Morph
*/
require_once dirname(__FILE__).'/../Morph.phar';
@@ -9,6 +10,9 @@
require_once dirname(__FILE__).'/test-objects/ComposeManyParent.php';
require_once dirname(__FILE__).'/test-objects/Child.php';
+/**
+ * @package Morph
+ */
class TestComposeMany extends MongoUnit_TestCase
{
View
4 mongodb-morph/integration-tests/TestComposeOne.php
@@ -2,6 +2,7 @@
/**
* @author Jonathan Moss <xirisr@gmail.com>
* @copyright 2010 Jonathan Moss
+ * @package Morph
*/
require_once dirname(__FILE__).'/../Morph.phar';
@@ -9,6 +10,9 @@
require_once dirname(__FILE__).'/test-objects/ComposeOneParent.php';
require_once dirname(__FILE__).'/test-objects/Child.php';
+/**
+ * @package Morph
+ */
class TestComposeOne extends MongoUnit_TestCase
{
View
4 mongodb-morph/integration-tests/TestFileProperty.php
@@ -2,12 +2,16 @@
/**
* @author Jonathan Moss <xirisr@gmail.com>
* @copyright 2010 Jonathan Moss
+ * @package Morph
*/
require_once dirname(__FILE__).'/../Morph.phar';
require_once dirname(__FILE__).'/MongoUnit/TestCase.php';
require_once dirname(__FILE__).'/test-objects/User.php';
+/**
+ * @package Morph
+ */
class TestFileProperty extends MongoUnit_TestCase
{
View
4 mongodb-morph/integration-tests/TestHasMany.php
@@ -2,6 +2,7 @@
/**
* @author Jonathan Moss <xirisr@gmail.com>
* @copyright 2010 Jonathan Moss
+ * @package Morph
*/
require_once dirname(__FILE__).'/../Morph.phar';
@@ -9,6 +10,9 @@
require_once dirname(__FILE__).'/test-objects/HasManyParent.php';
require_once dirname(__FILE__).'/test-objects/Child.php';
+/**
+ * @package Morph
+ */
class TestHasMany extends MongoUnit_TestCase
{
View
4 mongodb-morph/integration-tests/TestHasOne.php
@@ -2,6 +2,7 @@
/**
* @author Jonathan Moss <xirisr@gmail.com>
* @copyright 2010 Jonathan Moss
+ * @package Morph
*/
require_once dirname(__FILE__).'/../Morph.phar';
@@ -9,6 +10,9 @@
require_once dirname(__FILE__).'/test-objects/HasOneParent.php';
require_once dirname(__FILE__).'/test-objects/Child.php';
+/**
+ * @package Morph
+ */
class TestHasOne extends MongoUnit_TestCase
{
View
49 mongodb-morph/integration-tests/TestQuery.php
@@ -2,12 +2,16 @@
/**
* @author Jonathan Moss <xirisr@gmail.com>
* @copyright 2010 Jonathan Moss
+ * @package Morph
*/
require_once dirname(__FILE__).'/../Morph.phar';
require_once dirname(__FILE__).'/MongoUnit/TestCase.php';
require_once dirname(__FILE__).'/test-objects/Child.php';
+/**
+ * @package Morph
+ */
class TestQuery extends MongoUnit_TestCase
{
@@ -34,6 +38,15 @@ public function testCanFindByValue()
$this->assertEquals(1, $results->totalCount());
}
+ public function testCanFindByRegex()
+ {
+ $child = new Child();
+ $query = new Morph_Query();
+ $query->property('Name')->regex('/.*moose.*/i');
+ $results = $child->findByQuery($query);
+ $this->assertEquals(4, $results->totalCount());
+ }
+
public function testCanFindByLike()
{
$child = new Child();
@@ -42,4 +55,40 @@ public function testCanFindByLike()
$results = $child->findByQuery($query);
$this->assertEquals(4, $results->totalCount());
}
+
+ public function testCanFindByGreaterThan()
+ {
+ $child = new Child();
+ $query = new Morph_Query();
+ $query->property('Age')->greaterThan(22);
+ $results = $child->findByQuery($query);
+ $this->assertEquals(2, $results->totalCount());
+ }
+
+ public function testCanFindByLessThan()
+ {
+ $child = new Child();
+ $query = new Morph_Query();
+ $query->property('Age')->lessThan(22);
+ $results = $child->findByQuery($query);
+ $this->assertEquals(2, $results->totalCount());
+ }
+
+ public function testCanFindBetween()
+ {
+ $child = new Child();
+ $query = new Morph_Query();
+ $query->property('Age')->greaterThan(22)->lessThan(40);
+ $results = $child->findByQuery($query);
+ $this->assertEquals(1, $results->totalCount());
+ }
+
+ public function testCanFindByNotValue()
+ {
+ $child = new Child();
+ $query = new Morph_Query();
+ $query->property('Name')->notEqualTo('a_musing_moose');
+ $results = $child->findByQuery($query);
+ $this->assertEquals(3, $results->totalCount());
+ }
}
View
4 mongodb-morph/integration-tests/TestSingleObject.php
@@ -2,12 +2,16 @@
/**
* @author Jonathan Moss <xirisr@gmail.com>
* @copyright 2010 Jonathan Moss
+ * @package Morph
*/
require_once dirname(__FILE__).'/../Morph.phar';
require_once dirname(__FILE__).'/MongoUnit/TestCase.php';
require_once dirname(__FILE__).'/test-objects/Child.php';
+/**
+ * @package Morph
+ */
class TestSingleObject extends MongoUnit_TestCase
{
View
8 mongodb-morph/integration-tests/fixtures/children.json
@@ -1,6 +1,6 @@
[
- {"Name":"a_musing_moose"},
- {"Name":"a_moose_musing"},
- {"Name":"moose_musing_a"},
- {"Name":"musing_moose_a"}
+ {"Name":"a_musing_moose", "Age": 11},
+ {"Name":"a_moose_musing", "Age": 21},
+ {"Name":"moose_musing_a", "Age": 31},
+ {"Name":"musing_moose_a", "Age": 41}
]
View
1  mongodb-morph/integration-tests/test-objects/Child.php
@@ -6,6 +6,7 @@ public function __construct($id = null)
{
parent::__construct($id);
$this->addProperty(new Morph_Property_String('Name'));
+ $this->addProperty(new Morph_Property_Integer('Age'));
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.