public function testDeleteByIDs()
{
$book = $this->_createBook();
$firstPage = reset($book->ownPageList);
$book->ownPage[$firstPage->id] = NULL;
try {
R::store($book);
fail();
} catch (\Exception $e) {
pass();
}
$book = $this->_createBook();
asrt(count($book->ownPage), 2);
$firstPage = reset($book->ownPageList);
unset($book->ownPage[$firstPage->id]);
R::store($book);
$book = $book->fresh();
asrt(count($book->ownPage), 1);
$firstPage = reset($book->ownPageList);
$book->ownPage[$firstPage->id] = FALSE;
try {
R::store($book);
fail();
} catch (\Exception $e) {
pass();
}
$book = $book->fresh();
asrt(count($book->ownPage), 0);
$book = $this->_createBook();
$firstAd = reset($book->alias('magazine')->ownAd);
$book->alias('magazine')->ownAd[$firstAd->id] = NULL;
try {
R::store($book);
fail();
} catch (\Exception $e) {
pass();
}
$book = $this->_createBook();
asrt(count($book->alias('magazine')->ownAd), 3);
$firstAd = reset($book->alias('magazine')->ownAdList);
unset($book->alias('magazine')->ownAdList[$firstAd->id]);
R::store($book);
$book = $book->fresh();
asrt(count($book->alias('magazine')->ownAd), 2);
$firstAd = reset($book->alias('magazine')->ownAd);
$book->alias('magazine')->ownAd[$firstAd->id] = FALSE;
try {
R::store($book);
fail();
} catch (\Exception $e) {
pass();
}
$book = $book->fresh();
asrt(count($book->alias('magazine')->ownAd), 1);
}