public function testConditionsAndAliases()
{
R::nuke();
$author = R::xdispense(AUTHOR);
$author->name = 'Mr. Quill';
$book = R::xdispense(BOOK);
$book->title = 'Good Stories';
$book2 = R::xdispense(BOOK);
$book2->title = 'Good Stories 2';
$friend = R::xdispense(FRIEND);
$friend->name = 'Muse';
$publisher = R::xdispense(PUBLISHER);
$publisher->name = 'Good Books';
$author->{BOOKLIST} = array($book, $book2);
$author->{FRIENDLIST}[] = $friend;
$author->{PUBLISHER} = $publisher;
$coAuthor = R::xdispense(AUTHOR);
$coAuthor->name = 'Xavier';
$book2->{COAUTHOR} = $coAuthor;
R::store($author);
$author = $author->fresh();
asrt(R::count(AUTHOR), 2);
//Can we use with and withCondition?
asrt(count($author->{BOOKLIST}), 2);
asrt(count($author->with(' LIMIT 1 ')->{BOOKLIST}), 1);
asrt(count($author->withCondition(' title LIKE ? ', array('%2%'))->{BOOKLIST}), 1);
//Can we use an alias?
$book2 = $book2->fresh();
asrt($book2->fetchAs(AUTHOR)->{COAUTHOR}->name, 'Xavier');
$coAuthor = $book2->fetchAs(AUTHOR)->{COAUTHOR}->fresh();
asrt(count($coAuthor->alias(COAUTHOR)->{BOOKLIST}), 1);
}