Phalcon\Test\Unit\Mvc\Model\Transaction\ManagerTest::testTransactionRemovedOnRollback PHP Method

testTransactionRemovedOnRollback() public method

Tests transaction is removed when rolled back.
Since: 2016-04-09
Author: Nochum Sossonko ([email protected])
    public function testTransactionRemovedOnRollback()
    {
        $this->specify("Test does not remove transaction when rolled back", function () {
            $tm = new Manager();
            $transaction = $tm->get(true);
            $select = new Select();
            $select->setTransaction($transaction);
            $select->create(['name' => 'Crack of Dawn']);
            expect($this->tester->getProtectedProperty($tm, '_number'))->equals(1);
            expect($this->tester->getProtectedProperty($tm, '_transactions'))->count(1);
            try {
                $transaction->rollback();
            } catch (Failed $e) {
                // do nothing
            }
            expect($this->tester->getProtectedProperty($tm, '_number'))->equals(0);
            expect($this->tester->getProtectedProperty($tm, '_transactions'))->count(0);
        });
    }