Author: Grégoire Passault (g.passault@gmail.com)
Inheritance: extends Gregwar\Formidable\Language\LanguageAware
Ejemplo n.º 1
0
 /**
  * Testing adding a customized type
  */
 public function testFactoryCustomType()
 {
     $factory = new Factory();
     $factory->registerType('testing', '\\Gregwar\\Formidable\\Fields\\TextField');
     $form = $factory->getForm(__DIR__ . '/files/factory/testing.html');
     $html = "{$form}";
     $this->assertContains('text', $html);
     $this->assertEquals('Hello', $form->test);
 }
Ejemplo n.º 2
0
 /**
  * Testing file type
  */
 public function testFile()
 {
     $factory = new Factory();
     $factory->registerType('file', '\\FileField_NoSave');
     $form = $factory->getForm(__DIR__ . '/files/form/upload.html');
     $file = __DIR__ . '/files/upload/test.txt';
     $hash = sha1(file_get_contents($file));
     $this->assertContains('file', "{$form}");
     $this->assertContains('multipart', "{$form}");
     $this->assertAccept($form, array(), array('attachement' => array('size' => filesize($file), 'tmp_name' => $file, 'name' => 'test.txt')));
     $this->assertEquals($hash, $form->attachement->save(null));
     $this->assertEquals('test.txt', $form->getField('attachement')->fileName());
     $file = __DIR__ . '/files/upload/long.txt';
     $this->assertRefuse($form, array(), array('attachement' => array('size' => filesize($file), 'tmp_name' => $file, 'name' => 'long.txt')));
 }
Ejemplo n.º 3
0
 /**
  * Handling multiple files
  */
 public function testMultipleFiles()
 {
     $factory = new Factory();
     $factory->registerType('file', '\\FileField_NoSave');
     $form = $factory->getForm(__DIR__ . '/files/form/multiple_file.html');
     $file = __DIR__ . '/files/upload/test.txt';
     $this->assertAccept($form, array(), array('files' => array(0 => array('file' => array('size' => filesize($file), 'tmp_name' => $file, 'name' => 'a.txt')), 1 => array('file' => array('size' => filesize($file), 'tmp_name' => $file, 'name' => 'b.txt')))));
     $this->assertRefuse($form, array(), array('files' => array(0 => array('file' => array('size' => filesize($file), 'tmp_name' => $file, 'name' => 'a.txt')))));
 }