当前位置: 首页>>代码示例>>PHP>>正文


PHP Book::getReviews方法代码示例

本文整理汇总了PHP中Propel\Tests\Bookstore\Book::getReviews方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::getReviews方法的具体用法?PHP Book::getReviews怎么用?PHP Book::getReviews使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Propel\Tests\Bookstore\Book的用法示例。


在下文中一共展示了Book::getReviews方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testClearRefFk

 /**
  * Test the clearing of related object collection.
  * @link       http://www.propelorm.org/ticket/529
  */
 public function testClearRefFk()
 {
     BookstoreDataPopulator::populate();
     $book = new Book();
     $book->setISBN("Foo-bar-baz");
     $book->setTitle("The book title");
     // No save ...
     $r = new Review();
     $r->setReviewedBy('Me');
     $r->setReviewDate(new DateTime("now"));
     $book->addReview($r);
     // No save (yet) ...
     $this->assertEquals(1, count($book->getReviews()));
     $book->clearReviews();
     $this->assertEquals(0, count($book->getReviews()));
 }
开发者ID:rouffj,项目名称:Propel2,代码行数:20,代码来源:GeneratedObjectRelTest.php

示例2: testCountRefFk

 public function testCountRefFk()
 {
     $book = new Book();
     $book->setTitle("Test Book");
     $book->setISBN("TT-EE-SS-TT");
     $num = 5;
     for ($i = 2; $i < $num + 2; $i++) {
         $r = new Review();
         $r->setReviewedBy('Hans ' . $num);
         $dt = new DateTime("now");
         $dt->modify("-" . $i . " weeks");
         $r->setReviewDate($dt);
         $r->setRecommended($i % 2 == 0);
         $book->addReview($r);
     }
     $this->assertEquals($num, $book->countReviews(), "Expected countReviews to return {$num}");
     $this->assertEquals($num, count($book->getReviews()), "Expected getReviews to return {$num} reviews");
     $book->save();
     BookTableMap::clearInstancePool();
     ReviewTableMap::clearInstancePool();
     $book = BookQuery::create()->findPk($book->getId());
     $this->assertEquals($num, $book->countReviews(), "Expected countReviews() to return {$num} (after save)");
     $this->assertEquals($num, count($book->getReviews()), "Expected getReviews() to return {$num} (after save)");
     // Now set different criteria and expect different results
     $c = new Criteria();
     $c->add(ReviewTableMap::RECOMMENDED, false);
     $this->assertEquals(floor($num / 2), $book->countReviews($c), "Expected " . floor($num / 2) . " results from countReviews(recomm=false)");
     // Change Criteria, run again -- expect different.
     $c = new Criteria();
     $c->add(ReviewTableMap::RECOMMENDED, true);
     $this->assertEquals(ceil($num / 2), count($book->getReviews($c)), "Expected " . ceil($num / 2) . " results from getReviews(recomm=true)");
     $this->assertEquals($num, $book->countReviews(), "Expected countReviews to return {$num} with new empty Criteria");
 }
开发者ID:robin850,项目名称:Propel2,代码行数:33,代码来源:GeneratedObjectTest.php


注:本文中的Propel\Tests\Bookstore\Book::getReviews方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。