adding zend project folders into old campcaster.

This commit is contained in:
naomiaro 2010-12-07 14:19:27 -05:00
parent 56abfaf28e
commit 7ef0c18b26
4045 changed files with 1054952 additions and 0 deletions

View file

@ -0,0 +1,30 @@
<?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
*/
require_once dirname(__FILE__) . '/../../../runtime/lib/Propel.php';
require_once 'PHPUnit/Framework/TestCase.php';
/**
* Base functionality to be extended by all Propel test cases. Test
* case implementations are used to automate unit testing via PHPUnit.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author Daniel Rall <dlr@finemaltcoding.com> (Torque)
* @author Christopher Elkins <celkins@scardini.com> (Torque)
* @version $Revision: 1773 $
*/
abstract class BaseTestCase extends PHPUnit_Framework_TestCase {
/**
* Conditional compilation flag.
*/
const DEBUG = false;
}

View file

@ -0,0 +1,247 @@
<?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
*/
define('_LOB_SAMPLE_FILE_PATH', dirname(__FILE__) . '/../../../etc/lob');
/**
* Populates data needed by the bookstore unit tests.
*
* This classes uses the actual Propel objects to do the population rather than
* inserting directly into the database. This will have a performance hit, but will
* benefit from increased flexibility (as does anything using Propel).
*
* @author Hans Lellelid <hans@xmpl.org>
*/
class BookstoreDataPopulator
{
public static function populate($con = null)
{
if($con === null) {
$con = Propel::getConnection(BookPeer::DATABASE_NAME);
}
$con->beginTransaction();
// Add publisher records
// ---------------------
$scholastic = new Publisher();
$scholastic->setName("Scholastic");
// do not save, will do later to test cascade
$morrow = new Publisher();
$morrow->setName("William Morrow");
$morrow->save($con);
$morrow_id = $morrow->getId();
$penguin = new Publisher();
$penguin->setName("Penguin");
$penguin->save();
$penguin_id = $penguin->getId();
$vintage = new Publisher();
$vintage->setName("Vintage");
$vintage->save($con);
$vintage_id = $vintage->getId();
$rowling = new Author();
$rowling->setFirstName("J.K.");
$rowling->setLastName("Rowling");
// no save()
$stephenson = new Author();
$stephenson->setFirstName("Neal");
$stephenson->setLastName("Stephenson");
$stephenson->save($con);
$stephenson_id = $stephenson->getId();
$byron = new Author();
$byron->setFirstName("George");
$byron->setLastName("Byron");
$byron->save($con);
$byron_id = $byron->getId();
$grass = new Author();
$grass->setFirstName("Gunter");
$grass->setLastName("Grass");
$grass->save($con);
$grass_id = $grass->getId();
$phoenix = new Book();
$phoenix->setTitle("Harry Potter and the Order of the Phoenix");
$phoenix->setISBN("043935806X");
$phoenix->setAuthor($rowling);
$phoenix->setPublisher($scholastic);
$phoenix->setPrice(10.99);
$phoenix->save($con);
$phoenix_id = $phoenix->getId();
$qs = new Book();
$qs->setISBN("0380977427");
$qs->setTitle("Quicksilver");
$qs->setPrice(11.99);
$qs->setAuthor($stephenson);
$qs->setPublisher($morrow);
$qs->save($con);
$qs_id = $qs->getId();
$dj = new Book();
$dj->setISBN("0140422161");
$dj->setTitle("Don Juan");
$dj->setPrice(12.99);
$dj->setAuthor($byron);
$dj->setPublisher($penguin);
$dj->save($con);
$dj_id = $dj->getId();
$td = new Book();
$td->setISBN("067972575X");
$td->setTitle("The Tin Drum");
$td->setPrice(13.99);
$td->setAuthor($grass);
$td->setPublisher($vintage);
$td->save($con);
$td_id = $td->getId();
$r1 = new Review();
$r1->setBook($phoenix);
$r1->setReviewedBy("Washington Post");
$r1->setRecommended(true);
$r1->setReviewDate(time());
$r1->save($con);
$r1_id = $r1->getId();
$r2 = new Review();
$r2->setBook($phoenix);
$r2->setReviewedBy("New York Times");
$r2->setRecommended(false);
$r2->setReviewDate(time());
$r2->save($con);
$r2_id = $r2->getId();
$blob_path = _LOB_SAMPLE_FILE_PATH . '/tin_drum.gif';
$clob_path = _LOB_SAMPLE_FILE_PATH . '/tin_drum.txt';
$m1 = new Media();
$m1->setBook($td);
$m1->setCoverImage(file_get_contents($blob_path));
// CLOB is broken in PDO OCI, see http://pecl.php.net/bugs/bug.php?id=7943
if (get_class(Propel::getDB()) != "DBOracle") {
$m1->setExcerpt(file_get_contents($clob_path));
}
$m1->save($con);
// Add book list records
// ---------------------
// (this is for many-to-many tests)
$blc1 = new BookClubList();
$blc1->setGroupLeader("Crazyleggs");
$blc1->setTheme("Happiness");
$brel1 = new BookListRel();
$brel1->setBook($phoenix);
$brel2 = new BookListRel();
$brel2->setBook($dj);
$blc1->addBookListRel($brel1);
$blc1->addBookListRel($brel2);
$blc1->save();
$bemp1 = new BookstoreEmployee();
$bemp1->setName("John");
$bemp1->setJobTitle("Manager");
$bemp2 = new BookstoreEmployee();
$bemp2->setName("Pieter");
$bemp2->setJobTitle("Clerk");
$bemp2->setSupervisor($bemp1);
$bemp2->save($con);
$role = new AcctAccessRole();
$role->setName("Admin");
$bempacct = new BookstoreEmployeeAccount();
$bempacct->setBookstoreEmployee($bemp1);
$bempacct->setAcctAccessRole($role);
$bempacct->setLogin("john");
$bempacct->setPassword("johnp4ss");
$bempacct->save($con);
// Add bookstores
$store = new Bookstore();
$store->setStoreName("Amazon");
$store->setPopulationServed(5000000000); // world population
$store->setTotalBooks(300);
$store->save($con);
$store = new Bookstore();
$store->setStoreName("Local Store");
$store->setPopulationServed(20);
$store->setTotalBooks(500000);
$store->save($con);
$con->commit();
}
public static function populateOpinionFavorite($con = null)
{
if($con === null) {
$con = Propel::getConnection(BookPeer::DATABASE_NAME);
}
$con->beginTransaction();
$book1 = BookPeer::doSelectOne(new Criteria(), $con);
$reader1 = new BookReader();
$reader1->save($con);
$bo = new BookOpinion();
$bo->setBook($book1);
$bo->setBookReader($reader1);
$bo->save($con);
$rf = new ReaderFavorite();
$rf->setBookOpinion($bo);
$rf->save($con);
$con->commit();
}
public static function depopulate($con = null)
{
if($con === null) {
$con = Propel::getConnection(BookPeer::DATABASE_NAME);
}
$con->beginTransaction();
AuthorPeer::doDeleteAll($con);
BookstorePeer::doDeleteAll($con);
BookstoreContestPeer::doDeleteAll($con);
BookstoreContestEntryPeer::doDeleteAll($con);
BookstoreEmployeePeer::doDeleteAll($con);
BookstoreEmployeeAccountPeer::doDeleteAll($con);
BookstoreSalePeer::doDeleteAll($con);
BookClubListPeer::doDeleteAll($con);
BookOpinionPeer::doDeleteAll($con);
BookReaderPeer::doDeleteAll($con);
BookListRelPeer::doDeleteAll($con);
BookPeer::doDeleteAll($con);
ContestPeer::doDeleteAll($con);
CustomerPeer::doDeleteAll($con);
MediaPeer::doDeleteAll($con);
PublisherPeer::doDeleteAll($con);
ReaderFavoritePeer::doDeleteAll($con);
ReviewPeer::doDeleteAll($con);
$con->commit();
}
}

View file

@ -0,0 +1,38 @@
<?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
*/
require_once 'tools/helpers/bookstore/BookstoreTestBase.php';
require_once 'tools/helpers/bookstore/BookstoreDataPopulator.php';
/**
* Base class contains some methods shared by subclass test cases.
*/
abstract class BookstoreEmptyTestBase extends BookstoreTestBase
{
/**
* This is run before each unit test; it populates the database.
*/
protected function setUp()
{
parent::setUp();
BookstoreDataPopulator::depopulate($this->con);
}
/**
* This is run after each unit test. It empties the database.
*/
protected function tearDown()
{
BookstoreDataPopulator::depopulate($this->con);
parent::tearDown();
}
}

View file

@ -0,0 +1,47 @@
<?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
*/
require_once 'PHPUnit/Framework/TestCase.php';
set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes");
Propel::init('fixtures/bookstore/build/conf/bookstore-conf.php');
/**
* Base class contains some methods shared by subclass test cases.
*/
abstract class BookstoreTestBase extends PHPUnit_Framework_TestCase
{
protected $con;
/**
* This is run before each unit test; it populates the database.
*/
protected function setUp()
{
parent::setUp();
$this->con = Propel::getConnection(BookPeer::DATABASE_NAME);
$this->con->beginTransaction();
}
/**
* This is run after each unit test. It empties the database.
*/
protected function tearDown()
{
parent::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 PropelPDO::commit() in that case
// since it will trigger an exception on its own
// ('Cannot commit because a nested transaction was rolled back')
if ($this->con->isCommitable()) {
$this->con->commit();
}
}
}

View file

@ -0,0 +1,146 @@
<?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
*/
require_once 'tools/helpers/bookstore/BookstoreTestBase.php';
class BookstoreNestedSetTestBase extends BookstoreTestBase
{
public function dumpNodes($nodes)
{
$tree = array();
foreach ($nodes as $node) {
$tree[$node->getTitle()] = array($node->getLeftValue(), $node->getRightValue(), $node->getLevel());
}
return $tree;
}
/**
* Tree used for tests
* t1
* | \
* t2 t3
* | \
* t4 t5
* | \
* t6 t7
*/
protected function initTree()
{
Table9Peer::doDeleteAll();
$ret = array();
// shuffling the results so the db order is not the natural one
$fixtures = array(
't2' => array(2, 3, 1),
't5' => array(7, 12, 2),
't4' => array(5, 6, 2),
't7' => array(10, 11, 3),
't1' => array(1, 14, 0),
't6' => array(8, 9, 3),
't3' => array(4, 13, 1),
);
/* in correct order, this is:
't1' => array(1, 14, 0),
't2' => array(2, 3, 1),
't3' => array(4, 13, 1),
't4' => array(5, 6, 2),
't5' => array(7, 12, 2),
't6' => array(8, 9, 3),
't7' => array(10, 11, 3),
*/
foreach ($fixtures as $key => $data) {
$t = new PublicTable9();
$t->setTitle($key);
$t->setLeftValue($data[0]);
$t->setRightValue($data[1]);
$t->setLevel($data[2]);
$t->save();
$ret[$key]= $t;
}
// reordering the results in the fixtures
ksort($ret);
return array_values($ret);
}
protected function dumpTree()
{
$c = new Criteria();
$c->addAscendingOrderBycolumn(Table9Peer::TITLE);
return $this->dumpNodes(Table9Peer::doSelect($c));
}
/**
* Tree used for tests
* Scope 1
* t1
* | \
* t2 t3
* | \
* t4 t5
* | \
* t6 t7
* Scope 2
* t8
* | \
* t9 t10
*/
protected function initTreeWithScope()
{
Table10Peer::doDeleteAll();
$ret = array();
$fixtures = array(
't1' => array(1, 14, 0, 1),
't2' => array(2, 3, 1, 1),
't3' => array(4, 13, 1, 1),
't4' => array(5, 6, 2, 1),
't5' => array(7, 12, 2, 1),
't6' => array(8, 9, 3, 1),
't7' => array(10, 11, 3, 1),
't8' => array(1, 6, 0, 2),
't9' => array(2, 3, 1, 2),
't10' => array(4, 5, 1, 2),
);
foreach ($fixtures as $key => $data) {
$t = new PublicTable10();
$t->setTitle($key);
$t->setLeftValue($data[0]);
$t->setRightValue($data[1]);
$t->setLevel($data[2]);
$t->setScopeValue($data[3]);
$t->save();
$ret []= $t;
}
return $ret;
}
protected function dumpTreeWithScope($scope)
{
$c = new Criteria();
$c->add(Table10Peer::SCOPE_COL, $scope);
$c->addAscendingOrderBycolumn(Table10Peer::TITLE);
return $this->dumpNodes(Table10Peer::doSelect($c));
}
}
// we need this class to test protected methods
class PublicTable9 extends Table9
{
public $hasParentNode = null;
public $parentNode = null;
public $hasPrevSibling = null;
public $prevSibling = null;
public $hasNextSibling = null;
public $nextSibling = null;
}
class PublicTable10 extends Table10
{
public $hasParentNode = null;
public $parentNode = null;
}

View file

@ -0,0 +1,104 @@
<?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
*/
require_once 'tools/helpers/bookstore/BookstoreTestBase.php';
class BookstoreSortableTestBase extends BookstoreTestBase
{
protected function populateTable11()
{
Table11Peer::doDeleteAll();
$t1 = new Table11();
$t1->setRank(1);
$t1->setTitle('row1');
$t1->save();
$t2 = new Table11();
$t2->setRank(4);
$t2->setTitle('row4');
$t2->save();
$t3 = new Table11();
$t3->setRank(2);
$t3->setTitle('row2');
$t3->save();
$t4 = new Table11();
$t4->setRank(3);
$t4->setTitle('row3');
$t4->save();
}
protected function populateTable12()
{
/* List used for tests
scope=1 scope=2
row1 row5
row2 row6
row3
row4
*/
Table12Peer::doDeleteAll();
$t1 = new Table12();
$t1->setRank(1);
$t1->setScopeValue(1);
$t1->setTitle('row1');
$t1->save();
$t2 = new Table12();
$t2->setRank(4);
$t2->setScopeValue(1);
$t2->setTitle('row4');
$t2->save();
$t3 = new Table12();
$t3->setRank(2);
$t3->setScopeValue(1);
$t3->setTitle('row2');
$t3->save();
$t4 = new Table12();
$t4->setRank(1);
$t4->setScopeValue(2);
$t4->setTitle('row5');
$t4->save();
$t5 = new Table12();
$t5->setRank(3);
$t5->setScopeValue(1);
$t5->setTitle('row3');
$t5->save();
$t6 = new Table12();
$t6->setRank(2);
$t6->setScopeValue(2);
$t6->setTitle('row6');
$t6->save();
}
protected function getFixturesArray()
{
$c = new Criteria();
$c->addAscendingOrderByColumn(Table11Peer::RANK_COL);
$ts = Table11Peer::doSelect($c);
$ret = array();
foreach ($ts as $t) {
$ret[$t->getRank()] = $t->getTitle();
}
return $ret;
}
protected function getFixturesArrayWithScope($scope = null)
{
$c = new Criteria();
if ($scope !== null) {
$c->add(Table12Peer::SCOPE_COL, $scope);
}
$c->addAscendingOrderByColumn(Table12Peer::RANK_COL);
$ts = Table12Peer::doSelect($c);
$ret = array();
foreach ($ts as $t) {
$ret[$t->getRank()] = $t->getTitle();
}
return $ret;
}
}

View file

@ -0,0 +1,13 @@
<?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
*/
class DonothingBehavior extends Behavior
{
}

View file

@ -0,0 +1,83 @@
<?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
*/
class TestAuthor extends Author {
public function preInsert(PropelPDO $con = null)
{
parent::preInsert($con);
$this->setFirstName('PreInsertedFirstname');
return true;
}
public function postInsert(PropelPDO $con = null)
{
parent::postInsert($con);
$this->setLastName('PostInsertedLastName');
}
public function preUpdate(PropelPDO $con = null)
{
parent::preUpdate($con);
$this->setFirstName('PreUpdatedFirstname');
return true;
}
public function postUpdate(PropelPDO $con = null)
{
parent::postUpdate($con);
$this->setLastName('PostUpdatedLastName');
}
public function preSave(PropelPDO $con = null)
{
parent::preSave($con);
$this->setEmail("pre@save.com");
return true;
}
public function postSave(PropelPDO $con = null)
{
parent::postSave($con);
$this->setAge(115);
}
public function preDelete(PropelPDO $con = null)
{
parent::preDelete($con);
$this->setFirstName("Pre-Deleted");
return true;
}
public function postDelete(PropelPDO $con = null)
{
parent::postDelete($con);
$this->setLastName("Post-Deleted");
}
}
class TestAuthorDeleteFalse extends TestAuthor
{
public function preDelete(PropelPDO $con = null)
{
parent::preDelete($con);
$this->setFirstName("Pre-Deleted");
return false;
}
}
class TestAuthorSaveFalse extends TestAuthor
{
public function preSave(PropelPDO $con = null)
{
parent::preSave($con);
$this->setEmail("pre@save.com");
return false;
}
}

View file

@ -0,0 +1,183 @@
<?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
*/
class TestAllHooksBehavior extends Behavior
{
protected $tableModifier, $objectBuilderModifier, $peerBuilderModifier, $queryBuilderModifier;
public function getTableModifier()
{
if (is_null($this->tableModifier))
{
$this->tableModifier = new TestAllHooksTableModifier($this);
}
return $this->tableModifier;
}
public function getObjectBuilderModifier()
{
if (is_null($this->objectBuilderModifier))
{
$this->objectBuilderModifier = new TestAllHooksObjectBuilderModifier($this);
}
return $this->objectBuilderModifier;
}
public function getPeerBuilderModifier()
{
if (is_null($this->peerBuilderModifier))
{
$this->peerBuilderModifier = new TestAllHooksPeerBuilderModifier($this);
}
return $this->peerBuilderModifier;
}
public function getQueryBuilderModifier()
{
if (is_null($this->queryBuilderModifier))
{
$this->queryBuilderModifier = new TestAllHooksQueryBuilderModifier($this);
}
return $this->queryBuilderModifier;
}
}
class TestAllHooksTableModifier
{
protected $behavior, $table;
public function __construct($behavior)
{
$this->behavior = $behavior;
$this->table = $behavior->getTable();
}
public function modifyTable()
{
$this->table->addColumn(array(
'name' => 'test',
'type' => 'TIMESTAMP'
));
}
}
class TestAllHooksObjectBuilderModifier
{
public function objectAttributes($builder)
{
return 'public $customAttribute = 1;';
}
public function preSave($builder)
{
return '$this->preSave = 1;$this->preSaveIsAfterSave = isset($affectedRows);$this->preSaveBuilder="' . get_class($builder) . '";';
}
public function postSave($builder)
{
return '$this->postSave = 1;$this->postSaveIsAfterSave = isset($affectedRows);$this->postSaveBuilder="' . get_class($builder) . '";';
}
public function preInsert($builder)
{
return '$this->preInsert = 1;$this->preInsertIsAfterSave = isset($affectedRows);$this->preInsertBuilder="' . get_class($builder) . '";';
}
public function postInsert($builder)
{
return '$this->postInsert = 1;$this->postInsertIsAfterSave = isset($affectedRows);$this->postInsertBuilder="' . get_class($builder) . '";';
}
public function preUpdate($builder)
{
return '$this->preUpdate = 1;$this->preUpdateIsAfterSave = isset($affectedRows);$this->preUpdateBuilder="' . get_class($builder) . '";';
}
public function postUpdate($builder)
{
return '$this->postUpdate = 1;$this->postUpdateIsAfterSave = isset($affectedRows);$this->postUpdateBuilder="' . get_class($builder) . '";';
}
public function preDelete($builder)
{
return '$this->preDelete = 1;$this->preDeleteIsBeforeDelete = isset(Table3Peer::$instances[$this->id]);$this->preDeleteBuilder="' . get_class($builder) . '";';
}
public function postDelete($builder)
{
return '$this->postDelete = 1;$this->postDeleteIsBeforeDelete = isset(Table3Peer::$instances[$this->id]);$this->postDeleteBuilder="' . get_class($builder) . '";';
}
public function objectMethods($builder)
{
return 'public function hello() { return "' . get_class($builder) .'"; }';
}
public function objectCall($builder)
{
return 'if ($name == "foo") return "bar";';
}
public function objectFilter(&$string, $builder)
{
$string .= 'class testObjectFilter { const FOO = "' . get_class($builder) . '"; }';
}
}
class TestAllHooksPeerBuilderModifier
{
public function staticAttributes($builder)
{
return 'public static $customStaticAttribute = 1;public static $staticAttributeBuilder = "' . get_class($builder) . '";';
}
public function staticMethods($builder)
{
return 'public static function hello() { return "' . get_class($builder) . '"; }';
}
public function preSelect($builder)
{
return '$con->preSelect = "' . get_class($builder) . '";';
}
public function peerFilter(&$string, $builder)
{
$string .= 'class testPeerFilter { const FOO = "' . get_class($builder) . '"; }';
}
}
class TestAllHooksQueryBuilderModifier
{
public function preSelectQuery($builder)
{
return '// foo';
}
public function preDeleteQuery($builder)
{
return '// foo';
}
public function postDeleteQuery($builder)
{
return '// foo';
}
public function preUpdateQuery($builder)
{
return '// foo';
}
public function postUpdateQuery($builder)
{
return '// foo';
}
}

View file

@ -0,0 +1,29 @@
<?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
*/
/**
* A custom validator for ISBN.
*
* @author Hans Lellelid <hans@xmpl.org>
* @version $Revision: 1612 $
* @package propel.validator
*/
class ISBNValidator implements BasicValidator
{
const NOT_ISBN_REGEXP = '/[^0-9A-Z]/';
/**
* Whether the passed string matches regular expression.
*/
public function isValid (ValidatorMap $map, $str)
{
return !(preg_match(self::NOT_ISBN_REGEXP, $str));
}
}

View file

@ -0,0 +1,143 @@
<?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
*/
/**
* Populates data needed by the bookstore-cms unit tests.
*
* @author Hans Lellelid <hans@xmpl.org>
*/
class CmsDataPopulator {
public static function populate($con = null)
{
if($con === null)
{
$con = Propel::getConnection(PagePeer::DATABASE_NAME);
}
$con->beginTransaction();
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 1,194,'home')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 2,5,'school')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 6,43,'education')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 44,45,'simulator')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 46,47,'ac')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 3,4,'history')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 7,14,'master-mariner')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 8,9,'education')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 48,85,'courses')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 98,101,'contact')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 10,11,'entrance')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 104,191,'intra')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 102,103,'services')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 12,13,'competency')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 15,22,'watchkeeping-officer')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 16,17,'education')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 18,19,'entrance')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 20,21,'competency')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 31,38,'watchkeeping-engineer')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 32,33,'education')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 34,35,'entrance')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 36,37,'competency')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 39,40,'practice')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 86,97,'news')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 95,96,'2007-02')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 99,100,'personnel')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 87,88,'2007-06')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 49,50,'nautical')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 51,52,'radiotechnical')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 53,54,'resourcemgmt')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 57,58,'safety')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 59,60,'firstaid')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 61,62,'sar')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 67,84,'upcoming')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 65,66,'languages')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 55,56,'cargomgmt')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 119,120,'timetable')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 63,64,'boaters')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 105,118,'bulletinboard')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 106,107,'sdf')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 41,42,'fristaende')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 23,30,'ingenj')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 24,25,'utbildn')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 26,27,'ansokn')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 93,94,'utexaminerade')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 89,92,'Massan')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 192,193,'lankar')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 68,69,'FRB')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 70,71,'pelastautumis')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 72,73,'CCM')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 74,75,'sjukvard')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 121,188,'Veckoscheman')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 134,135,'VS3VSVsjukv')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 122,123,'sjoarb')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 130,131,'fysik1')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 140,141,'kemi')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 76,77,'inr')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 78,79,'forare')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 144,145,'AlexandraYH2')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 132,133,'AlexandraVS2')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 80,81,'Maskin')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 126,127,'forstahjalp')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 136,137,'Juridik')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 142,143,'mate')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 82,83,'basic')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 124,125,'mask')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 108,109,'magnus')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 138,139,'sjosakerhet')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 28,29,'pate')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 148,149,'eng')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 146,147,'forstahjalpYH1')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 110,111,'kortoverlevnadskurs')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 158,159,'kortoverlevnadskurs')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 128,129,'metall')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 152,153,'fysik')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 156,157,'fardplan')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 154,155,'astro')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 90,91,'utstallare')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 150,151,'eng')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 160,161,'ent')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 162,163,'juridik')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 168,169,'svenska')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 164,165,'matemat')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 166,167,'operativa')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 170,171,'plan')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 172,173,'src')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 112,113,'sjukv')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 174,175,'matemati')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 176,177,'fysiikka')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 114,115,'hantv')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 116,117,'CCM')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 178,179,'haveri')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 180,181,'FRB')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 182,183,'kemia')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 184,185,'vaktrutiner')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 189,190,'laroplan')");
$con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 186,187,'SSOkurs')");
$con->exec("INSERT INTO Category (LeftChild, RightChild, Title) VALUES (1, 8, 'Cat_1')");
$con->exec("INSERT INTO Category (LeftChild, RightChild, Title) VALUES (2, 7, 'Cat_1_1')");
$con->exec("INSERT INTO Category (LeftChild, RightChild, Title) VALUES (3, 6, 'Cat_1_1_1')");
$con->exec("INSERT INTO Category (LeftChild, RightChild, Title) VALUES (4, 5, 'Cat_1_1_1_1')");
$con->commit();
}
public static function depopulate($con = null)
{
if($con === null)
{
$con = Propel::getConnection(PagePeer::DATABASE_NAME);
}
$con->beginTransaction();
$con->exec("DELETE FROM Page");
$con->exec("DELETE FROM Category");
$con->commit();
}
}

View file

@ -0,0 +1,45 @@
<?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
*/
require_once 'PHPUnit/Framework/TestCase.php';
set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes");
Propel::init('fixtures/bookstore/build/conf/bookstore-conf.php');
include_once 'tools/helpers/cms/CmsDataPopulator.php';
/**
* Base class contains some methods shared by subclass test cases.
*/
abstract class CmsTestBase extends PHPUnit_Framework_TestCase
{
protected $con;
/**
* This is run before each unit test; it populates the database.
*/
protected function setUp()
{
parent::setUp();
$this->con = Propel::getConnection(PagePeer::DATABASE_NAME);
$this->con->beginTransaction();
CmsDataPopulator::depopulate($this->con);
CmsDataPopulator::populate($this->con);
}
/**
* This is run after each unit test. It empties the database.
*/
protected function tearDown()
{
CmsDataPopulator::depopulate($this->con);
$this->con->commit();
parent::tearDown();
}
}

View file

@ -0,0 +1,58 @@
<?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
*/
require_once 'phing/Task.php';
/**
* Defines a constant using PHP define() method.
*
* This is handy if you want to initialize a constant to a value that is available only as build properties.
*/
class DefineTask extends Task {
/**
* @var string
*/
private $name;
/**
* @var string
*/
private $value;
/**
* Sets the name for the constant.
* @param string $v
*/
public function setName($v) {
$this->name = $v;
}
/**
* Sets the value for the constant.
* @param string $v
*/
public function setValue($v) {
$this->value = $v;
}
public function main() {
if (!isset($this->name) || !isset($this->value)) {
throw new BuildException("Both name and value params are required.", $this->getLocation());
}
$const = strtoupper($this->name);
if (defined($const)) {
$this->log("The constant $const has already been defined!", Project::MSG_ERR);
} else {
define($const, $this->value);
$this->log("Defined $const with value " . var_export($this->value, true), Project::MSG_INFO);
}
}
}