-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee128c3
commit e0e0f97
Showing
2 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
namespace phpunit\Bundles\Exchange; | ||
|
||
use Exception; | ||
use PHPUnit\Framework\TestCase; | ||
use phpunit\Utils\Fakes\FakeExchangeFormat; | ||
use phpunit\Utils\Fakes\FakeStorage; | ||
use PHPUnuhi\Bundles\Exchange\ExchangeFactory; | ||
use PHPUnuhi\Bundles\Storage\StorageFactory; | ||
use PHPUnuhi\Exceptions\ConfigurationException; | ||
use PHPUnuhi\Models\Configuration\Filter; | ||
use PHPUnuhi\Models\Configuration\Protection; | ||
use PHPUnuhi\Models\Translation\TranslationSet; | ||
|
||
class ExchangeFactoryTest extends TestCase | ||
{ | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
ExchangeFactory::getInstance()->resetExchangeFormats(); | ||
} | ||
|
||
|
||
/** | ||
* @return void | ||
* @throws ConfigurationException | ||
*/ | ||
public function testGetCustomExchangeFormat(): void | ||
{ | ||
$custom = new FakeExchangeFormat(); | ||
ExchangeFactory::getInstance()->registerExchangeFormat($custom); | ||
|
||
$exchange = ExchangeFactory::getInstance()->getExchange('fake', []); | ||
|
||
$this->assertSame($custom, $exchange); | ||
} | ||
|
||
/** | ||
* @return void | ||
* @throws ConfigurationException | ||
*/ | ||
public function testDoubleRegistrationThrowsException(): void | ||
{ | ||
$this->expectException(Exception::class); | ||
|
||
$custom = new FakeExchangeFormat(); | ||
|
||
ExchangeFactory::getInstance()->registerExchangeFormat($custom); | ||
ExchangeFactory::getInstance()->registerExchangeFormat($custom); | ||
} | ||
|
||
/** | ||
* @return void | ||
* @throws ConfigurationException | ||
*/ | ||
public function testUnknownFormatThrowsException(): void | ||
{ | ||
$this->expectException(Exception::class); | ||
|
||
ExchangeFactory::getInstance()->getExchange('unknown', []); | ||
} | ||
|
||
/** | ||
* @return void | ||
* @throws ConfigurationException | ||
*/ | ||
public function testEmptyFormatThrowsException(): void | ||
{ | ||
$this->expectException(Exception::class); | ||
|
||
ExchangeFactory::getInstance()->getExchange('', []); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace phpunit\Utils\Fakes; | ||
|
||
use PHPUnuhi\Bundles\Exchange\ExchangeInterface; | ||
use PHPUnuhi\Bundles\Exchange\ImportResult; | ||
use PHPUnuhi\Models\Command\CommandOption; | ||
use PHPUnuhi\Models\Translation\TranslationSet; | ||
|
||
class FakeExchangeFormat implements ExchangeInterface | ||
{ | ||
|
||
public function getName(): string | ||
{ | ||
return 'fake'; | ||
} | ||
|
||
public function getOptions(): array | ||
{ | ||
// TODO: Implement getOptions() method. | ||
} | ||
|
||
public function setOptionValues(array $options): void | ||
{ | ||
// TODO: Implement setOptionValues() method. | ||
} | ||
|
||
public function export(TranslationSet $set, string $outputDir, bool $onlyEmpty): void | ||
{ | ||
// TODO: Implement export() method. | ||
} | ||
|
||
public function import(string $filename): ImportResult | ||
{ | ||
// TODO: Implement import() method. | ||
} | ||
|
||
|
||
} |