Пример #1
0
 public function testFileFieldByLabel()
 {
     $this->module->amOnPage('/form/file');
     $this->module->attachFile('Avatar', 'app/avatar.jpg');
     $this->module->click('Submit');
     $this->assertNotEmpty(data::get('files'));
 }
Пример #2
0
 /**
  * If we have a form with fields like
  * ```
  * <input type="file" name="foo" />
  * <input type="file" name="foo[bar]" />
  * ```
  * then only array variable will be used while simple variable will be ignored in php $_FILES
  * (eg $_FILES = [
  *                 foo => [
  *                     tmp_name => [
  *                         'bar' => 'asdf'
  *                     ],
  *                     //...
  *                ]
  *              ]
  * )
  * (notice there is no entry for file "foo", only for file "foo[bar]"
  * this will check if current element contains inner arrays within it's keys
  * so we can ignore element itself and only process inner files
  */
 public function testFormWithFilesInOnlyArray()
 {
     $this->shouldFail();
     $this->module->amOnPage('/form/example13');
     $this->module->attachFile('foo', 'app/avatar.jpg');
     $this->module->attachFile('foo[bar]', 'app/avatar.jpg');
     $this->module->click('Submit');
 }
Пример #3
0
 public function testFormWithFileSpecialCharNames()
 {
     $this->module->amOnPage('/form/example14');
     $this->module->attachFile('foo bar', 'app/avatar.jpg');
     $this->module->attachFile('foo.baz', 'app/avatar.jpg');
     $this->module->click('Submit');
     $this->assertNotEmpty(data::get('files'));
     $files = data::get('files');
     $this->assertNotEmpty($files);
     $this->assertArrayHasKey('foo_bar', $files);
     $this->assertArrayHasKey('foo_baz', $files);
 }
Пример #4
0
 /**
  * @Issue https://github.com/Codeception/Codeception/issues/1585
  * @Issue https://github.com/Codeception/Codeception/issues/1602
  */
 public function testUnreachableField()
 {
     $this->module->amOnPage('/form/bug1585');
     $this->module->fillField('textarea[name="captions[]"]', 'test2');
     $this->module->fillField('items[1][]', 'test3');
     $this->module->fillField('input[name="users[]"]', 'davert');
     $this->module->attachFile('input[name="files[]"]', 'app/avatar.jpg');
     $this->module->click('Submit');
     $data = data::get('form');
     $this->assertContains('test3', $data['items'][1]);
     $this->assertContains('test2', $data['captions']);
     $this->assertContains('davert', $data['users']);
 }