RedUNIT\Base\Association::testErrorHandling PHP Method

testErrorHandling() public method

On database systems providing informative SQL STATE error codes RedBeanPHP should not mind non-existing tables or columns in fluid mode.
public testErrorHandling ( ) : void
return void
    public function testErrorHandling()
    {
        R::nuke();
        list($book, $page) = R::dispenseAll('book,page');
        $book->sharedPage[] = $page;
        R::store($page);
        $redbean = R::getRedBean();
        $am = $redbean->getAssociationManager();
        //SQLite and CUBRID do not comply with ANSI SQLState codes.
        $catchAll = $this->currentlyActiveDriverID == 'sqlite' || $this->currentlyActiveDriverID === 'CUBRID';
        try {
            $am->related($book, 'page', 'invalid SQL');
            if ($catchAll) {
                pass();
            } else {
                fail();
            }
        } catch (SQL $e) {
            if ($catchAll) {
                fail();
            } else {
                pass();
            }
        }
        try {
            $am->related($book, 'cover');
            pass();
        } catch (SQL $e) {
            fail();
        }
        try {
            $am->related(R::dispense('cover'), 'book');
            pass();
        } catch (SQL $e) {
            fail();
        }
    }