UploadedFileTest.php 1.36 KiB
<?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());