コード例 #1
0
ファイル: FormHandlerTest.php プロジェクト: andyvenus/form
 public function testMultipleEntityAssignment()
 {
     $entity_one = new StandardFormEntity();
     $entity_one->setName('Name One');
     $entity_one->setDescription('Description One');
     $entity_one->setCategory('5');
     $entity_one->setPassword('Secure One');
     $entity_two = new StandardFormEntity();
     $entity_two->setName('Name Two');
     $entity_two->setDescription('Description Two');
     $entity_two->setCategory('1');
     $entity_two->setPassword('Secure Two');
     $this->standard_form_handler->bindEntity($entity_one, array('name', 'description'));
     $this->standard_form_handler->bindEntity($entity_two, array('name', 'password', 'category'));
     $this->assertEquals(2, count($this->standard_form_handler->getEntities()));
     $name_field = $this->standard_form_handler->getField('name');
     $this->assertEquals('Name Two', $name_field['value']);
     $description_field = $this->standard_form_handler->getField('description');
     $this->assertEquals('Description One', $description_field['value']);
     $_POST = $this->standard_form_request;
     $this->standard_form_handler->handleRequest();
     $this->standard_form_handler->saveToEntities();
     $this->assertEquals('Example Name', $entity_one->getName());
     $this->assertEquals('Example Description', $entity_one->getDescription());
     $this->assertEquals('5', $entity_one->getCategory());
     $this->assertEquals('Secure One', $entity_one->getPassword());
     $this->assertEquals('Example Name', $entity_two->getName());
     $this->assertEquals('Description Two', $entity_two->getDescription());
     $this->assertEquals('3', $entity_two->getCategory());
     $this->assertEquals('', $entity_two->getPassword());
 }