Esempio n. 1
0
 public function testSimpleEntityToArray()
 {
     // Before Store
     $role = new Role('toArray');
     $p1 = new Permission('l1');
     $p2 = new Permission('l1');
     $role->permissions->add($p1);
     $role->permissions->add($p2);
     $role->toArray();
     $rm = get_mapper($role);
     $rm->store($role);
     $role->toArray();
 }
Esempio n. 2
0
 public function testValueObjectWithMultipleFields()
 {
     $resource = new Resource('res');
     $rMapper = get_mapper($resource);
     $v = new V('v1', 'v2');
     $resource->value = $v;
     $rMapper->store($resource);
     $id = $resource->custom_id;
     $q = $rMapper->whereName('res')->first();
     $this->assertEquals('v1', $q->value->field_1);
     $this->assertEquals('v2', $q->value->field_2);
     // Add test for updating
     $z = $rMapper->find($id);
     $rMapper->store($z);
 }
Esempio n. 3
0
 public function testStoreAndHydrateLargeSets()
 {
     $pM = get_mapper('AnalogueTest\\App\\Permission');
     $perms = [];
     for ($x = 0; $x < 1000; $x++) {
         $perms[] = new Permission('large');
     }
     $pM->store($perms);
     $q = $pM->whereLabel('large')->get();
     $this->assertEquals(1000, $q->count());
 }
Esempio n. 4
0
 public function testMapperInit()
 {
     $mapper = get_mapper('Analogue\\ORM\\Entity');
     $this->assertEquals(get_class($mapper), 'Analogue\\ORM\\System\\Mapper');
 }
Esempio n. 5
0
 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));
 }
Esempio n. 6
0
 public function testSelfGeneratedPrimaryKey()
 {
     $uuid = new Uuid('test', 'testlabel');
     $um = get_mapper($uuid);
     $um->store($uuid);
     $this->assertEquals('test', $uuid->uuid);
     $uuid = $um->where('uuid', '=', 'test')->first();
     $this->assertEquals('test', $uuid->uuid);
     $this->assertEquals('testlabel', $uuid->label);
 }