Permalink
Browse files

adding tests for querying

git-svn-id: http://mongodb-morph.googlecode.com/svn/trunk@116 406649b4-5d4b-11de-8abc-d1c337b90d21
  • Loading branch information...
1 parent b85fbf7 commit 1bcc90fee8ddc52a5a2b2336d5ac97a10b7b4f07 XirisR committed Feb 1, 2010
View
45 mongodb-morph/integration-tests/TestQuery.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * @author Jonathan Moss <xirisr@gmail.com>
+ * @copyright 2010 Jonathan Moss
+ */
+
+require_once dirname(__FILE__).'/../Morph.phar';
+require_once dirname(__FILE__).'/MongoUnit/TestCase.php';
+require_once dirname(__FILE__).'/test-objects/Child.php';
+
+class TestSingleObject extends MongoUnit_TestCase
+{
+
+ public function setup()
+ {
+ parent::setup();
+ Morph_Storage::init($this->getDatabase());
+ //load data from file to query against
+ $this->loadJsonFileDatasetIntoCollection('Child', dirname(__FILE__). '/fixtures/children.json');
+ }
+
+ public function tearDown()
+ {
+ parent::tearDown();
+ Morph_Storage::deInit();
+ }
+
+ public function testCanFindByValue()
+ {
+ $child = new Child();
+ $query = new Morph_Query();
+ $query->property('Name')->equals('a_musing_moose');
+ $results = $child->findByQuery($query);
+ $this->assertEquals(1, $results->totalCount());
+ }
+
+ public function testCanFindByLike()
+ {
+ $child = new Child();
+ $query = new Morph_Query();
+ $query->property('Name')->like('moose');
+ $results = $child->findByQuery($query);
+ $this->assertEquals(4, $results->totalCount());
+ }
+}
View
1 mongodb-morph/integration-tests/fixtures/children.json
@@ -0,0 +1 @@
+[{"Name":"a_musing_moose"},{"Name":"a_moose_musing"},{"Name":"moose_musing_a"},{"Name":"musing_moose_a"}]

0 comments on commit 1bcc90f

Please sign in to comment.