protected function loadOnce() { $this->loadedCollection = $this->load(); foreach ($this->addedItems as $entity) { $this->loadedCollection->add($entity); } }
/** * Set the constraints for an eager load of the relation. * * @param array $entities * @return void */ public function addEagerConstraints(array $entities) { $this->buildDictionary($this->entities = EntityCollection::make($entities)); }
public function testSimplePaginate() { $mapper = get_mapper('AnalogueTest\\App\\Permission'); $c = new EntityCollection(); $y = 0; for ($x = 0; $x < 30; $x++) { $c->add(new Permission("P{$x}")); } $mapper->store($c); $paginator = $mapper->query()->simplePaginate(5); $this->assertEquals(5, count($paginator)); }
public function testExceptReturnsCollectionWithoutGivenModelKeys() { $e1 = new Entity(); $e1->id = 1; $e2 = new Entity(); $e2->id = '2'; $e3 = new Entity(); $e3->id = 3; $c = new Collection([$e1, $e2, $e3]); $this->assertEquals(new Collection(array($e1, $e3)), $c->except(2)); $this->assertEquals(new Collection(array($e1)), $c->except(array(2, 3))); }
public function testEntityLazyCollection() { $analogue = get_analogue(); $role = new Role('user'); $a = new Permission('P1'); $b = new Permission('P2'); $c = new Permission('P3'); $perms = new EntityCollection([$a, $b, $c]); $role->permissions = $perms; $analogue->mapper($role)->store($role); $ur = $analogue->query('AnalogueTest\\App\\Role')->whereLabel('user')->first(); $rawAttributes = $ur->getEntityAttributes(); $this->assertInstanceOf('Analogue\\ORM\\System\\CollectionProxy', $rawAttributes['permissions']); $this->assertInstanceOf('Analogue\\ORM\\EntityCollection', $rawAttributes['permissions']->load()); $this->assertEquals($perms->lists('label'), $ur->permissions->lists('label')); }