Skip to content

Commit

Permalink
fix(Repo): Deps
Browse files Browse the repository at this point in the history
  • Loading branch information
4513 committed May 8, 2024
1 parent 00ff9ec commit bbfce25
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 365 deletions.
2 changes: 1 addition & 1 deletion .idea/hub-currencies.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/php-docker-settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
"ext-curl": "*"
},
"require-dev": {
"phpunit/phpunit": "^10.5",
"phpunit/php-invoker": "^4.0",
"phpstan/phpstan": "^1.5",
"squizlabs/php_codesniffer": "^3.6"
"phpunit/phpunit": "^11.1",
"phpunit/php-invoker": "^5.0",
"phpstan/phpstan": "^1.10",
"squizlabs/php_codesniffer": "^3.9"
},
"config": {
"platform-check": true,
Expand Down
35 changes: 12 additions & 23 deletions tests/Core/ArrayListLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

use MiBo\Currencies\ISO\ISOArrayListLoader;
use MiBo\Currencies\ISO\ISOListLoader;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Small;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -18,44 +20,31 @@
* @since 1.2
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise.
*
* @coversDefaultClass \MiBo\Currencies\ISO\ISOArrayListLoader
*/
#[CoversClass(ISOArrayListLoader::class)]
#[Small]
class ArrayListLoaderTest extends TestCase
{
/**
* @small
*
* @covers ::loop
*
* @return void
*/
public function test(): void
{
$loader = new ISOArrayListLoader();

foreach ($loader->loop() as $currency) {
$this->assertIsObject($currency);
$this->assertSame("AFGHANISTAN", $currency->CtryNm);
$this->assertSame("Afghani", $currency->CcyNm);
$this->assertSame("AFN", $currency->Ccy);
$this->assertSame("971", $currency->CcyNbr);
$this->assertSame("2", $currency->CcyMnrUnts);
self::assertIsObject($currency);
self::assertSame("AFGHANISTAN", $currency->CtryNm);
self::assertSame("Afghani", $currency->CcyNm);
self::assertSame("AFN", $currency->Ccy);
self::assertSame("971", $currency->CcyNbr);
self::assertSame("2", $currency->CcyMnrUnts);

break;
}
}

/**
* @large
*
* @coversNothing
* @doesNotPerformAssertions
*
* @return void
*/
public function create(): void
{
self::expectNotToPerformAssertions();

return;

if (file_exists(__DIR__ . "/tmp.php")) {
Expand Down
107 changes: 23 additions & 84 deletions tests/Core/CachedFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use MiBo\Currencies\ISO\Exceptions\InvalidCacheDirException;
use MiBo\Currencies\ISO\Exceptions\UnavailableCurrencyListException;
use MiBo\Currencies\ISO\ISOLocalListLoader;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Small;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -13,9 +15,9 @@
* @package MiBo\Currencies\Tests
*
* @author Michal Boris <michal.boris27@gmail.com>
*
* @coversDefaultClass \MiBo\Currencies\ISO\ISOLocalListLoader
*/
#[CoversClass(ISOLocalListLoader::class)]
#[Small]
class CachedFileTest extends TestCase
{
protected const DIR_TMP = __DIR__ . "/../../storage/tmp/";
Expand All @@ -34,146 +36,83 @@ public static function setUpBeforeClass(): void
self::$loader = new ISOLocalListLoader(static::DIR_TMP);
}

/**
* @medium
*
* @covers ::updateFile
* @covers ::getCacheDir
*
* @return void
*/
public function testDownload(): void
{
$this->assertTrue($this->getLoader()->updateFile());
self::assertTrue($this->getLoader()->updateFile());

$this->assertFileExists(static::DIR_TMP . ISOLocalListLoader::FILE_NAME);
self::assertFileExists(static::DIR_TMP . ISOLocalListLoader::FILE_NAME);
}

/**
* @small
*
* @covers ::getCacheDir
* @covers ::setCacheDir
*
* @return void
*/
public function testCacheDir(): void
{
$this->assertSame(self::DIR_TMP, $this->getLoader()->getCacheDir());
self::assertSame(self::DIR_TMP, $this->getLoader()->getCacheDir());
$this->getLoader()->setCacheDir(__DIR__ . "/../../storage/");
$this->assertSame(__DIR__ . "/../../storage/", $this->getLoader()->getCacheDir());
self::assertSame(__DIR__ . "/../../storage/", $this->getLoader()->getCacheDir());
$this->getLoader()->setCacheDir(self::DIR_TMP);
}

/**
* @small
*
* @covers ::setResources
*
* @return void
*/
public function testSetResources(): void
{
$this->expectException(UnavailableCurrencyListException::class);
$this->expectExceptionMessage("Cannot use custom list of ISO currencies!");
self::expectException(UnavailableCurrencyListException::class);
self::expectExceptionMessage("Cannot use custom list of ISO currencies!");

$this->getLoader()->setResources("");
}

/**
* @small
*
* @covers ::addResource
*
* @return void
*/
public function testAddResource(): void
{
$this->expectException(UnavailableCurrencyListException::class);
$this->expectExceptionMessage("Cannot use custom list of ISO currencies!");
self::expectException(UnavailableCurrencyListException::class);
self::expectExceptionMessage("Cannot use custom list of ISO currencies!");

$this->getLoader()->addResource("");
}

/**
* @small
*
* @covers ::loop
* @covers ::contractLoop
*
* @return void
* @throws \MiBo\Currencies\ISO\Exceptions\UnavailableCurrencyListException
*/
public function testLoop(): void
{
foreach ($this->getLoader()->loop() as $object) {
$this->assertIsObject($object);
self::assertIsObject($object);

$this->assertNotNull($object->CtryNm);
self::assertNotNull($object->CtryNm);

$this->assertNotNull($object->CcyNm);
self::assertNotNull($object->CcyNm);

return;
}

$this->fail("Failed to loop the list.");
self::fail("Failed to loop the list.");
}

/**
* @small
*
* @covers ::updateFile
* @covers ::isFileCached
* @covers ::__construct
*
* @return void
*/
public function testCache(): void
{
static::tearDownAfterClass();

$loader = new ISOLocalListLoader(static::DIR_TMP);

$this->assertEmpty($loader->getResources());
self::assertEmpty($loader->getResources());

$loader->updateFile();

$this->assertNotEmpty($loader->getResources());
self::assertNotEmpty($loader->getResources());

$loader = new ISOLocalListLoader(static::DIR_TMP);

$this->assertNotEmpty($loader->getResources());
self::assertNotEmpty($loader->getResources());
}

/**
* @small
*
* @covers ::__construct
*
* @return void
*/
public function testInvalidDirectory(): void
{
$cacheDir = static::DIR_TMP . "test";

$this->expectException(InvalidCacheDirException::class);
$this->expectExceptionMessage("Directory '$cacheDir' does not exist!");
self::expectException(InvalidCacheDirException::class);
self::expectExceptionMessage("Directory '$cacheDir' does not exist!");

new ISOLocalListLoader($cacheDir);
}

/**
* @medium
*
* @covers ::loop
* @covers ::contractLoop
*
* @doesNotPerformAssertions
*
* @return void
*/
public function testLoopingCachedFile(): void
{
self::expectNotToPerformAssertions();

$this->getLoader()->updateFile();

$this->getLoader()->loop();
Expand Down
Loading

0 comments on commit bbfce25

Please sign in to comment.