| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
require_once 'PHPUnit/Framework/TestCase.php'; |
|---|
| 23 |
include_once 'bookstore/BookstoreDataPopulator.php'; |
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
abstract class BookstoreTestBase extends PHPUnit_Framework_TestCase { |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
* This is run before each unit test; it populates the database. |
|---|
| 32 |
*/ |
|---|
| 33 |
protected function setUp() |
|---|
| 34 |
{ |
|---|
| 35 |
parent::setUp(); |
|---|
| 36 |
BookstoreDataPopulator::depopulate(); |
|---|
| 37 |
BookstoreDataPopulator::populate(); |
|---|
| 38 |
} |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
* This is run after each unit test. It empties the database. |
|---|
| 42 |
*/ |
|---|
| 43 |
protected function tearDown() |
|---|
| 44 |
{ |
|---|
| 45 |
|
|---|
| 46 |
BookstoreDataPopulator::depopulate(); |
|---|
| 47 |
|
|---|
| 48 |
$this->assertEquals(0, count(BookPeer::doSelect(new Criteria())), "Expect book table to be empty."); |
|---|
| 49 |
$this->assertEquals(0, count(AuthorPeer::doSelect(new Criteria())), "Expect author table to be empty."); |
|---|
| 50 |
$this->assertEquals(0, count(PublisherPeer::doSelect(new Criteria())), "Expect publisher table to be empty."); |
|---|
| 51 |
$this->assertEquals(0, count(ReviewPeer::doSelect(new Criteria())), "Expect review table to be empty."); |
|---|
| 52 |
$this->assertEquals(0, count(MediaPeer::doSelect(new Criteria())), "Expect media table to be empty."); |
|---|
| 53 |
$this->assertEquals(0, count(BookstoreEmployeePeer::doSelect(new Criteria())), "Expect bookstore_employee table to be empty."); |
|---|
| 54 |
$this->assertEquals(0, count(BookstoreEmployeeAccountPeer::doSelect(new Criteria())), "Expect bookstore_employee_account table to be empty."); |
|---|
| 55 |
$this->assertEquals(0, count(BookstoreSalePeer::doSelect(new Criteria())), "Expect bookstore_sale table to be empty."); |
|---|
| 56 |
|
|---|
| 57 |
BookPeer::clearInstancePool(); |
|---|
| 58 |
$this->assertEquals(0, count(BookPeer::$instances), "Expected 0 Book instances after clearInstancePool()"); |
|---|
| 59 |
|
|---|
| 60 |
AuthorPeer::clearInstancePool(); |
|---|
| 61 |
$this->assertEquals(0, count(AuthorPeer::$instances), "Expected 0 Author instances after clearInstancePool()"); |
|---|
| 62 |
|
|---|
| 63 |
PublisherPeer::clearInstancePool(); |
|---|
| 64 |
$this->assertEquals(0, count(PublisherPeer::$instances), "Expected 0 Publisher instances after clearInstancePool()"); |
|---|
| 65 |
|
|---|
| 66 |
ReviewPeer::clearInstancePool(); |
|---|
| 67 |
$this->assertEquals(0, count(ReviewPeer::$instances), "Expected 0 Review instances after clearInstancePool()"); |
|---|
| 68 |
|
|---|
| 69 |
MediaPeer::clearInstancePool(); |
|---|
| 70 |
$this->assertEquals(0, count(MediaPeer::$instances), "Expected 0 Media instances after clearInstancePool()"); |
|---|
| 71 |
|
|---|
| 72 |
BookstoreEmployeePeer::clearInstancePool(); |
|---|
| 73 |
$this->assertEquals(0, count(BookstoreEmployeePeer::$instances), "Expected 0 BookstoreEmployee instances after clearInstancePool()"); |
|---|
| 74 |
|
|---|
| 75 |
BookstoreEmployeeAccountPeer::clearInstancePool(); |
|---|
| 76 |
$this->assertEquals(0, count(BookstoreEmployeeAccountPeer::$instances), "Expected 0 BookstoreEmployeeAccount instances after clearInstancePool()"); |
|---|
| 77 |
|
|---|
| 78 |
BookstoreSalePeer::clearInstancePool(); |
|---|
| 79 |
$this->assertEquals(0, count(BookstoreSalePeer::$instances), "Expected 0 BookstoreSale instances after clearInstancePool()"); |
|---|
| 80 |
|
|---|
| 81 |
parent::tearDown(); |
|---|
| 82 |
} |
|---|
| 83 |
|
|---|
| 84 |
} |
|---|
| 85 |
|
|---|