Add tested booker class

This commit is contained in:
Benoît Burnichon
2016-02-05 14:10:43 +01:00
parent 09ce98e21a
commit a539919cf8
4 changed files with 146 additions and 55 deletions

View File

@@ -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);

View 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)));
}
}