コード例 #1
0
 public function testLists()
 {
     $e1 = new Entity();
     $e1->uid = 'f';
     $e1->name = 'foo';
     $e2 = new Entity();
     $e2->uid = 'b';
     $e2->name = 'bar';
     $data = new Collection([$e1, $e2]);
     $this->assertEquals(new IlluminateCollection(['f' => 'foo', 'b' => 'bar']), $data->lists('name', 'uid'));
     $this->assertEquals(new IlluminateCollection(['foo', 'bar']), $data->lists('name'));
 }
コード例 #2
0
ファイル: DomainTest.php プロジェクト: maxmirazh33/analogue
 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'));
 }