Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
adding tests for querying
Browse files Browse the repository at this point in the history
git-svn-id: http://mongodb-morph.googlecode.com/svn/trunk@116 406649b4-5d4b-11de-8abc-d1c337b90d21
  • Loading branch information
XirisR authored and XirisR committed Feb 1, 2010
1 parent b85fbf7 commit 1bcc90f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
45 changes: 45 additions & 0 deletions mongodb-morph/integration-tests/TestQuery.php
Original file line number Diff line number Diff line change
@@ -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());
}
}
1 change: 1 addition & 0 deletions mongodb-morph/integration-tests/fixtures/children.json
Original file line number Diff line number Diff line change
@@ -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.