mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Add tested booker class
This commit is contained in:
@@ -639,35 +639,10 @@ class ManagerTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$this->object->unregisterChecker($uuidChecker);
|
||||
$this->assertEquals([$shaChecker, $filenameChecker], $this->object->getCheckers());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Border\Manager::bookLazaretPathfile
|
||||
*/
|
||||
public function testBookLazaretPathfile()
|
||||
{
|
||||
$manager = new ManagerTester(self::$DI['app']);
|
||||
|
||||
$file1 = $manager->bookLazaretPathfileTester('babebibobu.txt');
|
||||
$file2 = $manager->bookLazaretPathfileTester('babebibobu.txt');
|
||||
|
||||
$this->assertNotEquals($file2, $file1);
|
||||
|
||||
$this->assertTrue(file_exists($file1));
|
||||
$this->assertTrue(file_exists($file2));
|
||||
|
||||
unlink($file1);
|
||||
unlink($file2);
|
||||
}
|
||||
}
|
||||
|
||||
class ManagerTester extends Manager
|
||||
{
|
||||
|
||||
public function bookLazaretPathfileTester($filename)
|
||||
{
|
||||
return parent::bookLazaretPathfile($filename);
|
||||
}
|
||||
|
||||
public function addMediaAttributesTester($file)
|
||||
{
|
||||
return parent::addMediaAttributes($file);
|
||||
|
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2016 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\Filesystem;
|
||||
|
||||
use Alchemy\Phrasea\Filesystem\LazaretPathBooker;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use org\bovigo\vfs\vfsStreamDirectory;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
class LazaretPathBookerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var vfsStreamDirectory
|
||||
*/
|
||||
private $root;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->root = vfsStream::setup();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Border\Manager::bookLazaretPathfile
|
||||
*/
|
||||
public function testBookFile()
|
||||
{
|
||||
$mockedPathResolver = function ($path) {
|
||||
return $path;
|
||||
};
|
||||
|
||||
$sut = new LazaretPathBooker(new Filesystem(), $this->root->url(), $mockedPathResolver);
|
||||
|
||||
$file1 = $sut->bookFile('babebibobu.txt');
|
||||
$file2 = $sut->bookFile('babebibobu.txt');
|
||||
|
||||
$this->assertNotEquals($file2, $file1);
|
||||
|
||||
$this->assertCount(2, $this->root->getChildren());
|
||||
$this->assertTrue($this->root->hasChild(vfsStream::path($file1)));
|
||||
$this->assertTrue($this->root->hasChild(vfsStream::path($file2)));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user