Exemplo n.º 1
0
 public function testCascade()
 {
     $arr = ['users' => [['id' => 1], ['id' => 2]]];
     $entity = $this->helper->toEntity('Tests\\Role', $arr);
     $this->assertSame(2, $entity->getUsers()->count());
     $this->assertSame(1, $entity->getUsers()[0]->getId());
     $this->assertSame(2, $entity->getUsers()[1]->getId());
 }
Exemplo n.º 2
0
 public function testAllowedItems()
 {
     $user = new \Tests\User();
     $user->setId(10);
     $role = new \Tests\Role();
     $role->setId(1);
     $role->setName('foo');
     $user->setRole($role);
     $item = new \Tests\Item();
     $item->setId(20);
     $user->addItem($item);
     $settings = new \WebChemistry\Forms\Doctrine\Settings();
     $settings->setAllowedItems(['id', 'role' => ['id'], 'items' => ['id']]);
     $this->assertEquals(['id' => 10, 'role' => ['id' => 1], 'items' => [['id' => 20]]], $this->helper->toArray($user, $settings));
 }