mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
56 lines
1.6 KiB
PHP
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);
|
|
}
|
|
}
|