-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathExtensionTest.php
More file actions
33 lines (27 loc) · 1.34 KB
/
ExtensionTest.php
File metadata and controls
33 lines (27 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
namespace Rakit\Validation\Tests\Rules;
use Rakit\Validation\Rules\Extension;
use PHPUnit\Framework\TestCase;
class ExtensionTest extends TestCase
{
public function setUp()
{
$this->rule = new Extension;
}
public function testValids()
{
$this->assertTrue($this->rule->fillParameters(['pdf','png','txt'])->check('somefile.txt'));
$this->assertTrue($this->rule->fillParameters(['.pdf','.png','.txt'])->check('somefile.txt'));
$this->assertTrue($this->rule->fillParameters(['pdf','png','txt'])->check('path/to/somefile.txt'));
$this->assertTrue($this->rule->fillParameters(['pdf','png','txt'])->check('./absolute/path/to/somefile.txt'));
$this->assertTrue($this->rule->fillParameters(['pdf','png','txt'])->check('https://site.test/somefile.txt'));
}
public function testInvalids()
{
$this->assertFalse($this->rule->fillParameters(['pdf','png','txt'])->check(''));
$this->assertFalse($this->rule->fillParameters(['pdf','png','txt'])->check('.dotfile'));
$this->assertFalse($this->rule->fillParameters(['pdf','png','txt'])->check('notafile'));
$this->assertFalse($this->rule->fillParameters(['pdf','png','txt'])->check('somefile.php'));
$this->assertFalse($this->rule->fillParameters(['.pdf','.png','.txt'])->check('somefile.php'));
}
}