public function testConditions()
{
$result = $this->_db->conditions(null, null);
$this->assertEqual(array(), $result);
$function = 'function() { return this.x < y;}';
$conditions = new MongoCode($function);
$result = $this->_db->conditions($conditions, null);
$this->assertInternalType('array', $result);
$this->assertTrue(isset($result['$where']));
$this->assertEqual($conditions, $result['$where']);
$conditions = $function;
$result = $this->_db->conditions($conditions, null);
$this->assertInternalType('array', $result);
$this->assertTrue(isset($result['$where']));
$this->assertEqual($conditions, $result['$where']);
$conditions = array('key' => 'value', 'anotherkey' => 'some other value');
$result = $this->_db->conditions($conditions, null);
$this->assertInternalType('array', $result);
$this->assertEqual($conditions, $result);
$conditions = array('key' => array('one', 'two', 'three'));
$result = $this->_db->conditions($conditions, null);
$this->assertInternalType('array', $result);
$this->assertTrue(isset($result['key']));
$this->assertTrue(isset($result['key']['$in']));
$this->assertEqual($conditions['key'], $result['key']['$in']);
$conditions = array('$or' => array(array('key' => 'value'), array('other key' => 'another value')));
$result = $this->_db->conditions($conditions, null);
$this->assertTrue(isset($result['$or']));
$this->assertEqual($conditions['$or'][0]['key'], $result['$or'][0]['key']);
$conditions = array('$and' => array(array('key' => 'value'), array('other key' => 'another value')));
$result = $this->_db->conditions($conditions, null);
$this->assertTrue(isset($result['$and']));
$this->assertEqual($conditions['$and'][0]['key'], $result['$and'][0]['key']);
$conditions = array('$nor' => array(array('key' => 'value'), array('other key' => 'another value')));
$result = $this->_db->conditions($conditions, null);
$this->assertTrue(isset($result['$nor']));
$this->assertEqual($conditions['$nor'][0]['key'], $result['$nor'][0]['key']);
$conditions = array('key' => array('or' => array(1, 2)));
$result = $this->_db->conditions($conditions, null);
$this->assertEqual(array('key' => array('$or' => array(1, 2))), $result);
}