|
3 | 3 |
|
4 | 4 | class ValidatorTest extends \PHPUnit_Framework_TestCase |
5 | 5 | { |
| 6 | + protected $dir; |
| 7 | + protected $file; |
6 | 8 | protected $resource; |
7 | 9 | protected $nullValues; |
8 | 10 | protected $booleanValues; |
@@ -30,6 +32,8 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase |
30 | 32 | protected function setUp() |
31 | 33 | { |
32 | 34 | // Create resource/stream |
| 35 | + $this->dir = __DIR__ . '/fixtures'; |
| 36 | + $this->file = $this->dir . '/resource.txt'; |
33 | 37 | $this->resource = fopen(__DIR__ . '/fixtures/resource.txt', 'r'); |
34 | 38 |
|
35 | 39 | // Set values for each data type |
@@ -741,6 +745,43 @@ public function testValidateDateTime() |
741 | 745 | } |
742 | 746 | } |
743 | 747 |
|
| 748 | + /** |
| 749 | + * @covers Validator::validateResource |
| 750 | + */ |
| 751 | + public function testValidateResource() |
| 752 | + { |
| 753 | + $this->assertTrue(Validator::isResource($this->resource)); |
| 754 | + $this->assertTrue(Validator::isResource($this->resource, ['resource_type' => 'stream'])); |
| 755 | + } |
| 756 | + |
| 757 | + /** |
| 758 | + * @covers Validator::validateStream |
| 759 | + */ |
| 760 | + public function testValidateStream() |
| 761 | + { |
| 762 | + $this->assertTrue(Validator::isStream($this->resource)); |
| 763 | + } |
| 764 | + |
| 765 | + /** |
| 766 | + * @covers Validator::validateDir |
| 767 | + */ |
| 768 | + public function testValidateDir() |
| 769 | + { |
| 770 | + $this->assertTrue(Validator::isDir($this->dir)); |
| 771 | + $this->assertTrue(Validator::isDir($this->dir, ['is_writable' => true])); |
| 772 | + $this->assertFalse(Validator::isDir($this->dir, ['is_writable' => false])); |
| 773 | + } |
| 774 | + |
| 775 | + /** |
| 776 | + * @covers Validator::validateFile |
| 777 | + */ |
| 778 | + public function testValidateFile() |
| 779 | + { |
| 780 | + $this->assertTrue(Validator::isFile($this->file)); |
| 781 | + $this->assertTrue(Validator::isFile($this->file, ['is_writable' => true])); |
| 782 | + $this->assertFalse(Validator::isFile($this->file, ['is_writable' => false])); |
| 783 | + } |
| 784 | + |
744 | 785 | /** |
745 | 786 | * Test 'required' setting for rules. |
746 | 787 | */ |
|
0 commit comments