Files
Phraseanet/tests/Alchemy/Tests/Phrasea/Plugin/Importer/ImporterTest.php
2015-06-15 19:30:51 +02:00

56 lines
1.6 KiB
PHP

<?php
namespace Alchemy\Tests\Phrasea\Plugin\Importer;
use Alchemy\Phrasea\Plugin\Importer\Importer;
use Alchemy\Tests\Phrasea\Plugin\PluginTestCase;
/**
* @group functional
* @group legacy
*/
class ImporterTest extends PluginTestCase
{
public function testImport()
{
$source = 'here';
$target = 'there';
$strategy = $this->getMock('Alchemy\Phrasea\Plugin\Importer\ImportStrategy');
$strategy->expects($this->once())
->method('detect')
->with($source)
->will($this->returnValue('elephant'));
$importerInterface = $this->getMock('Alchemy\Phrasea\Plugin\Importer\ImporterInterface');
$importerInterface->expects($this->once())
->method('import')
->with($source, $target);
$importer = new Importer($strategy, ['elephant' => $importerInterface]);
$importer->import($source, $target);
}
/**
* @expectedException \Alchemy\Phrasea\Plugin\Exception\ImportFailureException
*/
public function testImportFailure()
{
$source = 'here';
$target = 'there';
$strategy = $this->getMock('Alchemy\Phrasea\Plugin\Importer\ImportStrategy');
$strategy->expects($this->once())
->method('detect')
->with($source)
->will($this->returnValue('elephant'));
$importerInterface = $this->getMock('Alchemy\Phrasea\Plugin\Importer\ImporterInterface');
$importerInterface->expects($this->never())
->method('import');
$importer = new Importer($strategy, ['rhinoceros' => $importerInterface]);
$importer->import($source, $target);
}
}