RedUNIT\Base\Association::testMySQL PHP Method

testMySQL() public method

Test MySQL specific issues with constraints.
public testMySQL ( ) : void
return void
    public function testMySQL()
    {
        if ($this->currentlyActiveDriverID !== 'mysql') {
            return;
        }
        testpack('Throw exception in case of issue with assoc constraint');
        $bunny = R::dispense('bunny');
        $carrot = R::dispense('carrot');
        $faultyWriter = new \FaultyWriter(R::getToolBox()->getDatabaseAdapter());
        $faultyOODB = new OODB($faultyWriter);
        $faultyOODB->setBeanHelper(R::getRedBean()->getBeanHelper());
        $faultyToolbox = new ToolBox($faultyOODB, R::getToolBox()->getDatabaseAdapter(), $faultyWriter);
        $faultyAssociationManager = new AssociationManager($faultyToolbox);
        $faultyWriter->setSQLState('23000');
        $faultyAssociationManager->associate($bunny, $carrot);
        pass();
        $faultyWriter->setSQLState('42S22');
        R::nuke();
        try {
            $faultyAssociationManager->associate($bunny, $carrot);
            fail();
        } catch (SQL $exception) {
            pass();
        }
    }