Skip to content

Commit

Permalink
Add test class FileElementTest
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 committed Jul 22, 2022
1 parent b3dd034 commit 9d59894
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/FormElement/FileElementTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace ipl\Tests\Html\FormElement;

use ipl\Html\FormElement\FileElement;
use ipl\Tests\Html\TestCase;

class FileElementTest extends TestCase
{
public function testFileElement()
{
$file = new FileElement('elname');

$this->assertHtml('<input name="elname" type="file"/>', $file);
}

public function testMultipleAttribute()
{
$file = new FileElement('elname', ['multiple' => true]);

$this->assertHtml('<input multiple name="elname[]" type="file"/>', $file);
}

public function testAcceptAttribute()
{
$file = new FileElement('elname', ['accept' => 'image/jpeg, image/png']);

$this->assertHtml('<input name="elname" type="file" accept="image/jpeg, image/png"/>', $file);
}

public function testSetValueDoesNotEffectAnything()
{
$file = new FileElement('elname');

$this->assertHtml('<input name="elname" type="file"/>', $file);

$file->setValue(5);
$this->assertHtml('<input name="elname" type="file"/>', $file);

$file->setValue('test');
$this->assertHtml('<input name="elname" type="file"/>', $file);

}
}

0 comments on commit 9d59894

Please sign in to comment.