CC-2166: Packaging Improvements. Moved the Zend app into airtime_mvc. It is now installed to /var/www/airtime. Storage is now set to /srv/airtime/stor. Utils are now installed to /usr/lib/airtime/utils/. Added install/airtime-dircheck.php as a simple test to see if everything is install/uninstalled correctly.

This commit is contained in:
Paul Baranowski 2011-04-14 18:55:04 -04:00
parent 514777e8d2
commit b11cbd8159
4546 changed files with 138 additions and 51 deletions

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));
}
}