Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 79 lines (70 sloc) 2.116 kb
4745077 Renamed folder
XirisR authored
1 <?php
2 /**
3 * @package Morph
4 * @author Jonathan Moss <xirisr@gmail.com>
5 * @copyright 2009 Jonathan Moss
6 * @version SVN: $Id$
7 */
380d4cf converted the whole project to namespaced PHP
Jonathan Moss authored
8 namespace morph;
4745077 Renamed folder
XirisR authored
9
380d4cf converted the whole project to namespaced PHP
Jonathan Moss authored
10 require_once dirname(__FILE__).'/../src/morph/Enum.php';
11 require_once dirname(__FILE__).'/../src/morph/IQuery.php';
12 require_once dirname(__FILE__).'/../src/morph/query/Property.php';
13 require_once dirname(__FILE__).'/../src/morph/Query.php';
4745077 Renamed folder
XirisR authored
14
15 /**
16 * @package Morph
17 */
380d4cf converted the whole project to namespaced PHP
Jonathan Moss authored
18 class TestQuery extends \PHPUnit_Framework_TestCase
4745077 Renamed folder
XirisR authored
19 {
20
21 public function testLimit()
22 {
380d4cf converted the whole project to namespaced PHP
Jonathan Moss authored
23 $query = new Query();
4745077 Renamed folder
XirisR authored
24 $query->limit(10);
25 $this->assertEquals(10, $query->getLimit());
26 }
27
28 public function testSkip()
29 {
380d4cf converted the whole project to namespaced PHP
Jonathan Moss authored
30 $query = new Query();
4745077 Renamed folder
XirisR authored
31 $query->skip(10);
32 $this->assertEquals(10, $query->getSkip());
33 }
34
35 public function testProperty()
36 {
ef14615 git-svn-id: http://mongodb-morph.googlecode.com/svn/trunk@103 406649b4-5...
XirisR authored
37 $expected = array('bob' => 'hoskins');
380d4cf converted the whole project to namespaced PHP
Jonathan Moss authored
38 $query = new Query();
ef14615 git-svn-id: http://mongodb-morph.googlecode.com/svn/trunk@103 406649b4-5...
XirisR authored
39 $query->property('bob')->equals('hoskins');
4745077 Renamed folder
XirisR authored
40 $this->assertEquals($expected, $query->getRawQuery());
41
42 }
43
44 public function testFluent()
45 {
46 $expected = array('bob' => 'hoskins');
380d4cf converted the whole project to namespaced PHP
Jonathan Moss authored
47 $query = Query::instance()
48 ->property('bob')
4745077 Renamed folder
XirisR authored
49 ->equals('hoskins');
50 $this->assertEquals($expected, $query->getRawQuery());
51 }
52
53 public function testMultipleProperties()
54 {
55 $expected = array('bob' => 'hoskins', 'abc' => 12);
380d4cf converted the whole project to namespaced PHP
Jonathan Moss authored
56 $query = Query::instance()
57 ->property('bob')
4745077 Renamed folder
XirisR authored
58 ->equals('hoskins')
59 ->property('abc')
60 ->equals(12);
61 $this->assertEquals($expected, $query->getRawQuery());
62 }
63
64 public function testFullFluency()
65 {
66 $expected = array('bob' => 'hoskins', 'abc' => 12);
380d4cf converted the whole project to namespaced PHP
Jonathan Moss authored
67 $query = Query::instance()
68 ->limit(10)->skip(12)
4745077 Renamed folder
XirisR authored
69 ->property('bob')
70 ->equals('hoskins')
f908b71 git-svn-id: http://mongodb-morph.googlecode.com/svn/trunk@107 406649b4-5...
XirisR authored
71 ->sort(1)
4745077 Renamed folder
XirisR authored
72 ->property('abc')
73 ->equals(12);
74 $this->assertEquals($expected, $query->getRawQuery());
75 $this->assertEquals(10, $query->getLimit());
76 $this->assertEquals(12, $query->getSkip());
f908b71 git-svn-id: http://mongodb-morph.googlecode.com/svn/trunk@107 406649b4-5...
XirisR authored
77 $this->assertEquals(array('bob'=>1), $query->getRawSort());
4745077 Renamed folder
XirisR authored
78 }
380d4cf converted the whole project to namespaced PHP
Jonathan Moss authored
79 }
Something went wrong with that request. Please try again.