public function testIncludesHitsCache() { $queries = 0; $this->connection()->filterChain()->onQuery(function ($sql) use(&$queries) { ++$queries; return $sql; }); // the first lookup of SecretIdentity should cache all the rest $heros = Hero::all()->includes(array('SecretIdentity'))->toArray(); $this->assertNotNull($heros[0]->SecretIdentity); // these should be from cache $queries = 0; $this->assertNotNull($heros[1]->SecretIdentity); $this->assertNotNull($heros[2]->SecretIdentity); $this->assertEquals(0, $queries, "this should have hit the cache"); }
public function testJoiningAndFiltering() { $collection = Hero::all()->join(array('Powers', 'SecretIdentity'))->filter('SecretIdentity.realname = ?', "Peter Parker"); $this->assertCount(1 * 2, $collection); $this->assertEquals("Spider Man", $collection[0]->alias); }