Source

						public function testSimpleQueryRender() {
		$result = $this->db->renderCommand(new Query(array(
			'type' => 'read',
			'model' => $this->_model,
			'fields' => array('id', 'title', 'created')
		)));
		$fields = 'id, title, created';
		$table = '{mock_database_posts} AS {MockDatabasePost}';
		$expected = "SELECT MockDatabasePost.id, MockDatabasePost.title, MockDatabasePost.created"
						. " FROM {$table};";
		$this->assertEqual($expected, $result);

		$result = $this->db->renderCommand(new Query(array(
			'type' => 'read',
			'model' => $this->_model,
			'fields' => array('id', 'title', 'created'),
			'limit' => 1
		)));
		$expected = 'SELECT MockDatabasePost.id, MockDatabasePost.title, MockDatabasePost.created'
						. ' FROM {mock_database_posts} AS {MockDatabasePost} ';
		$expected .= 'LIMIT 1;';
		$this->assertEqual($expected, $result);

		$result = $this->db->renderCommand(new Query(array(
			'type' => 'read',
			'model' => $this->_model,
			'fields' => array('id', 'title', 'created'),
			'limit' => 1,
			'conditions' => 'Post.id = 2'
		)));
		$expected = 'SELECT MockDatabasePost.id, MockDatabasePost.title, MockDatabasePost.created'
						. ' FROM {mock_database_posts} AS {MockDatabasePost} ';
		$expected .= 'WHERE Post.id = 2 LIMIT 1;';
		$this->assertEqual($expected, $result);
	}