Example #1
0
 public function testInput()
 {
     $request = new MockHTTPRequest(['text' => 'sometext']);
     $text = (new \Forms\Components\TextArea("text"))->setID('text-id')->setClass('text-class')->setDecorator('<div class="text-field"> %s </div>')->setLabel('TextArea')->setPlaceholder('Text Area')->setValidators([new \Forms\Validators\Required()]);
     $this->assertEquals($this->componentProvider(), $text->render($request->getParsedBody(), []), "Text Area did not render correctly.");
     $this->assertTrue($text->validate($request), "Text Area did not validate.");
 }
Example #2
0
 public function testInput()
 {
     $request = new MockHTTPRequest(['identifier' => 'username']);
     $input = (new \Forms\Components\Input("identifier"))->setType('text')->setValue('username')->setAutocomplete('off')->setID('input-id')->setClass('input-class')->setDecorator('<div class="input-field"> %s </div>')->setLabel('User / Email')->setPlaceholder('Identifier')->setValidators([new \Forms\Validators\Required()]);
     $this->assertEquals($this->componentProvider(), $input->render($request->getParsedBody(), []), "Input did not render correctly.");
     $this->assertTrue($input->validate($request), "Input did not validate.");
 }
Example #3
0
 public function testFileInput()
 {
     $request = new MockHTTPRequest();
     $fileInput = (new \Forms\Components\FileInput("upload"))->setID('upload-id')->setClass('upload-class')->setDecorator('<div class="upload-field"> %s </div>')->setLabel('Upload a file');
     $this->assertEquals($this->componentProvider(), $fileInput->render($request->getParsedBody(), []), "FileInput did not render correctly.");
 }