public function testIssue9and10()
{
$toolbox = R::getToolBox();
$redbean = $toolbox->getRedBean();
$adapter = $toolbox->getDatabaseAdapter();
$a = new AssociationManager($toolbox);
$book = $redbean->dispense("book");
$author1 = $redbean->dispense("author");
$author2 = $redbean->dispense("author");
$book->title = "My First Post";
$author1->name = "Derek";
$author2->name = "Whoever";
$a->associate($book, $author1);
$a->associate($book, $author2);
pass();
testpack("Test Association Issue Group keyword (Issues 9 and 10)");
R::nuke();
$group = $redbean->dispense("group");
$group->name = "mygroup";
$redbean->store($group);
try {
$a->associate($group, $book);
pass();
} catch (SQL $e) {
fail();
}
// Test issue SQL error 23000
try {
$a->associate($group, $book);
pass();
} catch (SQL $e) {
fail();
}
asrt((int) $adapter->getCell("select count(*) from book_group"), 1);
//just 1 rec!
}