本文整理汇总了PHP中BookstoreDataPopulator类的典型用法代码示例。如果您正苦于以下问题:PHP BookstoreDataPopulator类的具体用法?PHP BookstoreDataPopulator怎么用?PHP BookstoreDataPopulator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BookstoreDataPopulator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
parent::setUp();
BookstoreDataPopulator::populate($this->con);
Propel::disableInstancePooling();
$this->books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find();
}
开发者ID:halfer,项目名称:Meshing,代码行数:7,代码来源:PropelOnDemandCollectionTest.php
示例2: setUp
/**
* This is run before each unit test; it empties the database.
*/
protected function setUp()
{
parent::setUp();
if (static::$isInitialized) {
BookstoreDataPopulator::depopulate($this->con);
}
}
开发者ID:disider,项目名称:Propel2,代码行数:10,代码来源:BookstoreEmptyTestBase.php
示例3: tearDown
/**
* This is run after each unit test. It empties the database.
*/
protected function tearDown()
{
BookstoreDataPopulator::depopulate();
$this->assertEquals(0, count(BookPeer::doSelect(new Criteria())), "Expect book table to be empty.");
$this->assertEquals(0, count(AuthorPeer::doSelect(new Criteria())), "Expect author table to be empty.");
$this->assertEquals(0, count(PublisherPeer::doSelect(new Criteria())), "Expect publisher table to be empty.");
$this->assertEquals(0, count(ReviewPeer::doSelect(new Criteria())), "Expect review table to be empty.");
$this->assertEquals(0, count(MediaPeer::doSelect(new Criteria())), "Expect media table to be empty.");
$this->assertEquals(0, count(BookstoreEmployeePeer::doSelect(new Criteria())), "Expect bookstore_employee table to be empty.");
$this->assertEquals(0, count(BookstoreEmployeeAccountPeer::doSelect(new Criteria())), "Expect bookstore_employee_account table to be empty.");
$this->assertEquals(0, count(BookstoreSalePeer::doSelect(new Criteria())), "Expect bookstore_sale table to be empty.");
BookPeer::clearInstancePool();
$this->assertEquals(0, count(BookPeer::$instances), "Expected 0 Book instances after clearInstancePool()");
AuthorPeer::clearInstancePool();
$this->assertEquals(0, count(AuthorPeer::$instances), "Expected 0 Author instances after clearInstancePool()");
PublisherPeer::clearInstancePool();
$this->assertEquals(0, count(PublisherPeer::$instances), "Expected 0 Publisher instances after clearInstancePool()");
ReviewPeer::clearInstancePool();
$this->assertEquals(0, count(ReviewPeer::$instances), "Expected 0 Review instances after clearInstancePool()");
MediaPeer::clearInstancePool();
$this->assertEquals(0, count(MediaPeer::$instances), "Expected 0 Media instances after clearInstancePool()");
BookstoreEmployeePeer::clearInstancePool();
$this->assertEquals(0, count(BookstoreEmployeePeer::$instances), "Expected 0 BookstoreEmployee instances after clearInstancePool()");
BookstoreEmployeeAccountPeer::clearInstancePool();
$this->assertEquals(0, count(BookstoreEmployeeAccountPeer::$instances), "Expected 0 BookstoreEmployeeAccount instances after clearInstancePool()");
BookstoreSalePeer::clearInstancePool();
$this->assertEquals(0, count(BookstoreSalePeer::$instances), "Expected 0 BookstoreSale instances after clearInstancePool()");
parent::tearDown();
}
开发者ID:JimmyVB,项目名称:Symfony-v1.2,代码行数:32,代码来源:BookstoreTestBase.php
示例4: testExplainPlanFromString
public function testExplainPlanFromString()
{
BookstoreDataPopulator::depopulate($this->con);
BookstoreDataPopulator::populate($this->con);
$db = Propel::getDb(BookPeer::DATABASE_NAME);
$query = 'SELECT book.TITLE AS Title FROM book INNER JOIN author ON (book.AUTHOR_ID=author.ID) WHERE author.FIRST_NAME = \'Neal\'';
$stmt = $db->doExplainPlan($this->con, $query);
$explain = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($db instanceof DBMySQL) {
$this->assertEquals(sizeof($explain), 2, 'Explain plan return two lines');
// explain can change sometime, test can't be strict
$this->assertArrayHasKey('select_type', $explain[0], 'Line 1, select_type key exist');
$this->assertArrayHasKey('table', $explain[0], 'Line 1, table key exist');
$this->assertArrayHasKey('type', $explain[0], 'Line 1, type key exist');
$this->assertArrayHasKey('possible_keys', $explain[0], 'Line 1, possible_keys key exist');
$this->assertArrayHasKey('select_type', $explain[1], 'Line 2, select_type key exist');
$this->assertArrayHasKey('table', $explain[1], 'Line 2, table key exist');
$this->assertArrayHasKey('type', $explain[1], 'Line 2, type key exist');
$this->assertArrayHasKey('possible_keys', $explain[1], 'Line 2, possible_keys key exist');
} elseif ($db instanceof DBOracle) {
$this->assertTrue(sizeof($explain) > 2, 'Explain plan return more than 2 lines');
} else {
$this->markTestSkipped('Cannot test explain plan on adapter ' . get_class($db));
}
}
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:25,代码来源:ExplainPlanTest.php
示例5: testQuery
public function testQuery()
{
BookstoreDataPopulator::depopulate();
BookstoreDataPopulator::populate();
$book = PropelQuery::from('Book b')->where('b.Title like ?', 'Don%')->orderBy('b.ISBN', 'desc')->findOne();
$this->assertTrue($book instanceof Book);
$this->assertEquals('Don Juan', $book->getTitle());
}
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:8,代码来源:PropelQueryTest.php
示例6: setUp
protected function setUp()
{
parent::setUp();
BookstoreDataPopulator::populate();
$this->sampleLobFiles['tin_drum.gif'] = TESTS_BASE_DIR . '/etc/lob/tin_drum.gif';
$this->sampleLobFiles['tin_drum.txt'] = TESTS_BASE_DIR . '/etc/lob/tin_drum.txt';
$this->sampleLobFiles['propel.gif'] = TESTS_BASE_DIR . '/etc/lob/propel.gif';
}
开发者ID:kcornejo,项目名称:estadistica,代码行数:8,代码来源:GeneratedObjectLobTest.php
示例7: testDeleteAllFilter
public function testDeleteAllFilter()
{
BookstoreDataPopulator::depopulate($this->con);
$manager = new BookstoreManager();
$manager->save($this->con);
$cashier1 = new BookstoreCashier();
$cashier1->save($this->con);
$cashier2 = new BookstoreCashier();
$cashier2->save($this->con);
BookstoreManagerQuery::create()->deleteAll();
$nbCash = BookstoreEmployeeQuery::create()->count();
$this->assertEquals(2, $nbCash, 'Delete in sub query affects only child results');
}
开发者ID:keneanung,项目名称:gw2spidy,代码行数:13,代码来源:QueryBuilderInheritanceTest.php
示例8: setUp
protected function setUp()
{
parent::setUp();
BookstoreDataPopulator::populate();
$cr = new Criteria();
$cr->add(AuthorPeer::LAST_NAME, "Rowling");
$cr->add(AuthorPeer::FIRST_NAME, "J.K.");
$rowling = AuthorPeer::doSelectOne($cr);
$this->authorId = $rowling->getId();
$book = new Book();
$book->setTitle("Harry Potter and the Philosopher's Stone");
$book->setISBN("1234");
$book->setAuthor($rowling);
$book->save();
$this->books[] = $book->getId();
$book = new Book();
$book->setTitle("Harry Potter and the Chamber of Secrets");
$book->setISBN("1234");
$book->setAuthor($rowling);
$book->save();
$this->books[] = $book->getId();
$book = new Book();
$book->setTitle("Harry Potter and the Prisoner of Azkaban");
$book->setISBN("1234");
$book->setAuthor($rowling);
$book->save();
$this->books[] = $book->getId();
$book = new Book();
$book->setTitle("Harry Potter and the Goblet of Fire");
$book->setISBN("1234");
$book->setAuthor($rowling);
$book->save();
$this->books[] = $book->getId();
$book = new Book();
$book->setTitle("Harry Potter and the Half-Blood Prince");
$book->setISBN("1234");
$book->setAuthor($rowling);
$book->save();
$this->books[] = $book->getId();
$book = new Book();
$book->setTitle("Harry Potter and the Deathly Hallows");
$book->setISBN("1234");
$book->setAuthor($rowling);
$book->save();
$this->books[] = $book->getId();
}
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:46,代码来源:PropelPagerTest.php
示例9: testUpdateOneByOne
public function testUpdateOneByOne()
{
$con = Propel::getConnection(BookPeer::DATABASE_NAME);
BookstoreDataPopulator::depopulate($con);
BookstoreDataPopulator::populate($con);
// save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved
$c = new ModelCriteria('bookstore', 'Book');
$books = $c->find();
foreach ($books as $book) {
$book->save();
}
$count = $con->getQueryCount();
$c = new ModelCriteria('bookstore', 'Book');
$nbBooks = $c->update(array('Title' => 'foo'), $con, true);
$this->assertEquals(4, $nbBooks, 'update() returns the number of updated rows');
$this->assertEquals($count + 1 + 4, $con->getQueryCount(), 'update() updates the objects one by one when called with true as last parameter');
$c = new ModelCriteria('bookstore', 'Book', 'b');
$c->where('b.Title = ?', 'foo');
$nbBooks = $c->count();
$this->assertEquals(4, $nbBooks, 'update() updates all records by default');
BookstoreDataPopulator::depopulate($con);
BookstoreDataPopulator::populate($con);
// save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved
$c = new ModelCriteria('bookstore', 'Book');
$books = $c->find();
foreach ($books as $book) {
$book->save();
}
$count = $con->getQueryCount();
$c = new ModelCriteria('bookstore', 'Book', 'b');
$c->where('b.Title = ?', 'Don Juan');
$nbBooks = $c->update(array('ISBN' => '3456'), $con, true);
$this->assertEquals(1, $nbBooks, 'update() updates only the records matching the criteria');
$this->assertEquals($count + 1 + 1, $con->getQueryCount(), 'update() updates the objects one by one when called with true as last parameter');
$c = new ModelCriteria('bookstore', 'Book', 'b');
$c->where('b.Title = ?', 'Don Juan');
$book = $c->findOne();
$this->assertEquals('3456', $book->getISBN(), 'update() updates only the records matching the criteria');
}
开发者ID:ketheriel,项目名称:ETVA,代码行数:39,代码来源:ModelCriteriaTest.php
示例10: testPruneCompositeKey
public function testPruneCompositeKey()
{
BookstoreDataPopulator::depopulate();
BookstoreDataPopulator::populate();
// save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved
$c = new ModelCriteria('bookstore', 'Book');
$books = $c->find();
foreach ($books as $book) {
$book->save();
}
BookPeer::clearInstancePool();
$nbBookListRel = BookListRelQuery::create()->prune()->count();
$this->assertEquals(2, $nbBookListRel, 'prune() does nothing when passed a null object');
$testBookListRel = BookListRelQuery::create()->findOne();
$nbBookListRel = BookListRelQuery::create()->prune($testBookListRel)->count();
$this->assertEquals(1, $nbBookListRel, 'prune() removes an object from the result');
}
开发者ID:shelsonjava,项目名称:datawrapper,代码行数:17,代码来源:QueryBuilderTest.php
示例11: testFormatSingleTableInheritanceManyResults
public function testFormatSingleTableInheritanceManyResults()
{
$con = Propel::getConnection(BookPeer::DATABASE_NAME);
BookstoreDataPopulator::populate($con);
$stmt = $con->query('SELECT * FROM bookstore_employee');
$formatter = new PropelOnDemandFormatter();
$formatter->init(new ModelCriteria('bookstore', 'BookstoreEmployee'));
$employees = $formatter->format($stmt);
foreach ($employees as $employee) {
$row = array();
$row[1] = $employee->getClassKey();
$omClass = BookstoreEmployeePeer::getOMClass($row, 0, false);
$actualClass = get_class($employee);
$this->assertEquals($omClass, $actualClass, 'PropelOnDemandFormatter::format() should handle single table inheritance');
}
}
开发者ID:kcornejo,项目名称:estadistica,代码行数:16,代码来源:PropelOnDemandFormatterTest.php
示例12: setUp
protected function setUp()
{
parent::setUp();
BookstoreDataPopulator::populate();
require_once 'tools/helpers/bookstore/validator/ISBNValidator.php';
}
开发者ID:nextbigsound,项目名称:propel-orm,代码行数:6,代码来源:ValidatorTest.php
示例13: setUp
protected function setUp()
{
parent::setUp();
BookstoreDataPopulator::populate();
require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/validator/ISBNValidator.php';
}
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:6,代码来源:ValidatorTest.php
示例14: testSelectArrayPaginate
public function testSelectArrayPaginate()
{
BookstoreDataPopulator::depopulate($this->con);
BookstoreDataPopulator::populate($this->con);
$pager = BookQuery::create()->select(array('Id', 'Title', 'ISBN', 'Price'))->paginate(1, 10, $this->con);
$this->assertInstanceOf('PropelModelPager', $pager);
foreach ($pager as $result) {
$this->assertEquals(array('Id', 'Title', 'ISBN', 'Price'), array_keys($result));
}
}
开发者ID:keneanung,项目名称:gw2spidy,代码行数:10,代码来源:ModelCriteriaSelectTest.php
示例15: setUp
protected function setUp()
{
parent::setUp();
BookstoreDataPopulator::populate($this->con);
}
开发者ID:keneanung,项目名称:gw2spidy,代码行数:5,代码来源:PropelObjectCollectionWithFixturesTest.php
示例16: testFindOneWithClassAndColumn
public function testFindOneWithClassAndColumn()
{
BookstoreDataPopulator::populate();
BookPeer::clearInstancePool();
AuthorPeer::clearInstancePool();
ReviewPeer::clearInstancePool();
$c = new ModelCriteria('bookstore', 'Book');
$c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND);
$c->filterByTitle('The Tin Drum');
$c->join('Book.Author');
$c->withColumn('Author.FirstName', 'AuthorName');
$c->withColumn('Author.LastName', 'AuthorName2');
$c->with('Author');
$c->limit(1);
$con = Propel::getConnection(BookPeer::DATABASE_NAME);
$books = $c->find($con);
foreach ($books as $book) {
break;
}
$this->assertTrue($book instanceof Book, 'withColumn() do not change the resulting model class');
$this->assertEquals('The Tin Drum', $book->getTitle());
$this->assertTrue($book->getAuthor() instanceof Author, 'PropelObjectFormatter correctly hydrates with class');
$this->assertEquals('Gunter', $book->getAuthor()->getFirstName(), 'PropelObjectFormatter correctly hydrates with class');
$this->assertEquals('Gunter', $book->getVirtualColumn('AuthorName'), 'PropelObjectFormatter adds withColumns as virtual columns');
$this->assertEquals('Grass', $book->getVirtualColumn('AuthorName2'), 'PropelObjectFormatter correctly hydrates all virtual columns');
}
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:26,代码来源:PropelOnDemandFormatterWithTest.php
示例17: testSelectArrayWithColumn
public function testSelectArrayWithColumn()
{
BookstoreDataPopulator::depopulate($this->con);
BookstoreDataPopulator::populate($this->con);
$c = new ModelCriteria('bookstore', 'Book');
$c->join('Book.Author');
$c->withColumn('LOWER(Book.Title)', 'LowercaseTitle');
$c->select(array('LowercaseTitle', 'Book.Title'));
$c->orderBy('Book.Title');
$rows = $c->find($this->con);
$expectedSQL = 'SELECT LOWER(book.TITLE) AS LowercaseTitle, book.TITLE AS "Book.Title" FROM `book` INNER JOIN `author` ON (book.AUTHOR_ID=author.ID) ORDER BY book.TITLE ASC';
$this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'find() called after select(array) can cope with a column added with withColumn()');
$expectedRows = array(array('LowercaseTitle' => 'don juan', 'Book.Title' => 'Don Juan'), array('LowercaseTitle' => 'harry potter and the order of the phoenix', 'Book.Title' => 'Harry Potter and the Order of the Phoenix'), array('LowercaseTitle' => 'quicksilver', 'Book.Title' => 'Quicksilver'), array('LowercaseTitle' => 'the tin drum', 'Book.Title' => 'The Tin Drum'));
$this->assertEquals(serialize($rows->getData()), serialize($expectedRows), 'find() called after select(array) can cope with a column added with withColumn()');
}
开发者ID:rubensayshi,项目名称:propelsandbox,代码行数:15,代码来源:ModelCriteriaSelectTest.php
示例18: testToArrayIncludeForeignObjects
public function testToArrayIncludeForeignObjects()
{
BookstoreDataPopulator::populate();
BookPeer::clearInstancePool();
AuthorPeer::clearInstancePool();
PublisherPeer::clearInstancePool();
$c = new Criteria();
$c->add(BookPeer::TITLE, 'Don Juan');
$books = BookPeer::doSelectJoinAuthor($c);
$book = $books[0];
$arr1 = $book->toArray(BasePeer::TYPE_PHPNAME, null, true);
$expectedKeys = array('Id', 'Title', 'ISBN', 'Price', 'PublisherId', 'AuthorId', 'Author');
$this->assertEquals($expectedKeys, array_keys($arr1), 'toArray() can return sub arrays for hydrated related objects');
$this->assertEquals('George', $arr1['Author']['FirstName'], 'toArray() can return sub arrays for hydrated related objects');
$c = new Criteria();
$c->add(BookPeer::TITLE, 'Don Juan');
$books = BookPeer::doSelectJoinAll($c);
$book = $books[0];
$arr2 = $book->toArray(BasePeer::TYPE_PHPNAME, null, true);
$expectedKeys = array('Id', 'Title', 'ISBN', 'Price', 'PublisherId', 'AuthorId', 'Publisher', 'Author');
$this->assertEquals($expectedKeys, array_keys($arr2), 'toArray() can return sub arrays for hydrated related objects');
}
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:22,代码来源:GeneratedObjectTest.php
示例19: testToArrayLazyLoad
/**
* Test the toArray() method with new lazyLoad param.
* @link http://propel.phpdb.org/trac/ticket/527
*/
public function testToArrayLazyLoad()
{
BookstoreDataPopulator::populate();
$c = new Criteria();
$c->add(MediaPeer::COVER_IMAGE, null, Criteria::NOT_EQUAL);
$c->add(MediaPeer::EXCERPT, null, Criteria::NOT_EQUAL);
$m = MediaPeer::doSelectOne($c);
if ($m === null) {
$this->fail("Test requires at least one media row w/ cover_image and excerpt NOT NULL");
}
$arr1 = $m->toArray(BasePeer::TYPE_COLNAME);
$this->assertNotNull($arr1[MediaPeer::COVER_IMAGE]);
$this->assertType('resource', $arr1[MediaPeer::COVER_IMAGE]);
$arr2 = $m->toArray(BasePeer::TYPE_COLNAME, false);
$this->assertNull($arr2[MediaPeer::COVER_IMAGE]);
$this->assertNull($arr2[MediaPeer::EXCERPT]);
$diffKeys = array_keys(array_diff($arr1, $arr2));
$expectedDiff = array(MediaPeer::COVER_IMAGE, MediaPeer::EXCERPT);
$this->assertEquals($expectedDiff, $diffKeys);
}
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:24,代码来源:GeneratedObjectTest.php
示例20: setUp
protected function setUp()
{
parent::setUp();
BookstoreDataPopulator::depopulate();
BookstoreDataPopulator::populate();
}
开发者ID:kcornejo,项目名称:estadistica,代码行数:6,代码来源:ModelCriteriaHooksTest.php
注:本文中的BookstoreDataPopulator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论