コード例 #1
0
ファイル: Collection.php プロジェクト: lytc/sloths
 /**
  * @param bool $reload
  * @return $this
  */
 public function load($reload = false)
 {
     if ((null === $this->models || $reload) && $this->select) {
         $rows = $this->select->all();
         $this->triggerEventListener('load', [&$rows]);
         $this->setRows($rows);
     }
     return $this;
 }
コード例 #2
0
ファイル: SelectTest.php プロジェクト: lytc/sloths
 public function testAllWithCache()
 {
     $rows = [['id' => 1]];
     $cacheManager = $this->getMock('Sloths\\Cache\\CacheManager', ['get']);
     $cacheManager->expects($this->once())->method('get')->with(Select::CACHE_KEY_PREFIX . '.' . md5("SELECT users.* FROM users"))->willReturnCallback(function ($key, &$success) use($rows) {
         $success = true;
         return $rows;
     });
     $select = new Select();
     $select->setCacheManager($cacheManager);
     $select->table('users')->remember(10);
     $this->assertSame($rows, $select->all());
 }