Pheasant\Tests\Transaction\TransactionTest::testDeferEventsFireOnRollback PHP Method

testDeferEventsFireOnRollback() public method

    public function testDeferEventsFireOnRollback()
    {
        $connection = \Mockery::mock('\\Pheasant\\Database\\Mysqli\\Connection');
        $connection->shouldReceive('execute')->with('BEGIN')->once();
        $connection->shouldReceive('execute')->with('ROLLBACK')->once();
        $events = \Mockery::mock();
        $events->shouldReceive('cork')->once()->andReturn($events);
        $events->shouldReceive('discard')->once()->andReturn($events);
        $events->shouldReceive('uncork')->once()->andReturn($events);
        $transaction = new Transaction($connection);
        $transaction->deferEvents($events);
        $transaction->callback(function () {
            throw new \Exception("Llamas :( :)");
        });
        $this->setExpectedException('\\Exception');
        $transaction->execute();
    }