ExtensionTest

The Gravity PDF ExtensionTest class.

Defined (1)

The class is defined in the following location(s).

/vendor/codeguy/upload/tests/Validation/ExtensionTest.php  
  1. class ExtensionTest extends PHPUnit_Framework_TestCase 
  2. /** 
  3. * Setup (each test) 
  4. */ 
  5. public function setUp() 
  6. // Path to test assets 
  7. $this->assetsDirectory = dirname(__DIR__) . '/assets'; 
  8.  
  9. // Create stubbed storage instance 
  10. $this->storage = $this->getMock( 
  11. '\Upload\Storage\FileSystem',  
  12. array('upload'),  
  13. array($this->assetsDirectory) 
  14. ); 
  15. $this->storage->expects($this->any()) 
  16. ->method('upload') 
  17. ->will($this->returnValue(true)); 
  18.  
  19. // Reset $_FILES superglobal 
  20. $_FILES['foo'] = array( 
  21. 'name' => 'foo.txt',  
  22. 'tmp_name' => $this->assetsDirectory . '/foo.txt',  
  23. 'error' => 0 
  24. ); 
  25.  
  26. public function testValidExtension() 
  27. $file = new \Upload\File('foo', $this->storage); 
  28. $validation = new \Upload\Validation\Extension('txt'); 
  29. $this->assertTrue($validation->validate($file)); 
  30.  
  31. public function testInvalidExtension() 
  32. $file = new \Upload\File('foo', $this->storage); 
  33. $validation = new \Upload\Validation\Extension('csv'); 
  34. $this->assertFalse($validation->validate($file));