Commit a7d94be9 authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

Ajout de tests pour UploadedFile.

Showing with 58 additions and 0 deletions
+58 -0
<?php
namespace Irstea\FileUploadBundle\Tests\Entity;
use Irstea\FileUploadBundle\Entity\UploadedFile;
use PHPUnit_Framework_TestCase;
/**
* Generated by PHPUnit_SkeletonGenerator on 2015-01-26 at 10:27:46.
*/
class UploadedFileTest extends PHPUnit_Framework_TestCase
{
/**
* @var UploadedFile
*/
protected $file;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->file = new UploadedFile;
}
/**
* @covers Irstea\FileUploadBundle\Entity\UploadedFile::isSafePath
* @dataProvider getIsSafePathvalues
*/
public function testIsSafePath($isSafe, $path)
{
$this->assertEquals($isSafe, UploadedFile::isSafePath($path));
}
public function getIsSafePathvalues()
{
return [
[true, 'toto.php'],
[false, '../toto.php'],
[true, 'bla/../toto.php'],
[false, 'bla/.././../toto.php'],
[false, '/../toto.php'],
[true, '/bla/../toto.php'],
[false, '../toto.php']
];
}
public function testMoveTo()
{
$this->file->setPath('truc/muche');
$this->file->moveTo('machin/chose/');
$this->assertEquals('machin/chose/muche', $this->file->getPath());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment