Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 90e860ab8f
Fetching contributors…

Cannot retrieve contributors at this time

76 lines (65 sloc) 1.998 kB
<?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
namespace Propel\Tests\Helpers\Bookstore;
use Propel\Runtime\Propel;
use Propel\Tests\Bookstore\BookPeer;
/**
* Base class contains some methods shared by subclass test cases.
*/
abstract class BookstoreTestBase extends \PHPUnit_Framework_TestCase
{
/**
* @var Boolean
*/
private static $isInitialized = false;
/**
* @var \PDO
*/
protected $con;
public static function setUpBeforeClass()
{
if (true !== self::$isInitialized) {
Propel::init(__DIR__ . '/../../../../Fixtures/bookstore/build/conf/bookstore-conf.php');
self::$isInitialized = true;
}
}
/**
* This is run before each unit test; it populates the database.
*/
protected function setUp()
{
$this->con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
$this->con->beginTransaction();
}
/**
* This is run after each unit test. It empties the database.
*/
protected function tearDown()
{
// Only commit if the transaction hasn't failed.
// This is because tearDown() is also executed on a failed tests,
// and we don't want to call ConnectionInterface::commit() in that case
// since it will trigger an exception on its own
// ('Cannot commit because a nested transaction was rolled back')
if (null !== $this->con) {
if ($this->con->isCommitable()) {
$this->con->commit();
}
$this->con = null;
}
}
protected function getDriver()
{
return $this->con->getAttribute(\PDO::ATTR_DRIVER_NAME);
}
public static function tearDownAfterClass()
{
Propel::getServiceContainer()->closeConnections();
}
}
Jump to Line
Something went wrong with that request. Please try again.