Skip to content

Commit

Permalink
Change tests namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Aug 7, 2024
1 parent 0c485d0 commit 358f74f
Show file tree
Hide file tree
Showing 55 changed files with 219 additions and 106 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
"autoload-dev": {
"psr-4": {
"ICanBoogie\\CLDR\\": "tests"
"Test\\ICanBoogie\\CLDR\\": "tests"
}
}
}
6 changes: 3 additions & 3 deletions lib/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function format_datetime(
DateTimeInterface|int|string $datetime,
string|DateTimeFormatLength $pattern_or_length_or_skeleton
): string {
return $this->datetime_formatter->format($datetime, $pattern_or_length_or_skeleton);
return $this->get_datetime_formatter()->format($datetime, $pattern_or_length_or_skeleton);
}

/**
Expand All @@ -189,7 +189,7 @@ public function format_date(
DateTimeInterface|int|string $datetime,
string|DateTimeFormatLength $pattern_or_length_or_skeleton
): string {
return $this->date_formatter->format($datetime, $pattern_or_length_or_skeleton);
return $this->get_date_formatter()->format($datetime, $pattern_or_length_or_skeleton);
}

/**
Expand All @@ -199,7 +199,7 @@ public function format_time(
DateTimeInterface|int|string $datetime,
string|DateTimeFormatLength $pattern_or_length_or_skeleton
): string {
return $this->time_formatter->format($datetime, $pattern_or_length_or_skeleton);
return $this->get_time_formatter()->format($datetime, $pattern_or_length_or_skeleton);
}

/**
Expand Down
8 changes: 6 additions & 2 deletions tests/Cache/CacheCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
* file that was distributed with this source code.
*/

namespace ICanBoogie\CLDR\Cache;
namespace Test\ICanBoogie\CLDR\Cache;

use ICanBoogie\CLDR\Cache;
use const ICanBoogie\CLDR\CACHE_DIR;
use ICanBoogie\CLDR\Cache\CacheCollection;
use ICanBoogie\CLDR\Cache\FileCache;
use ICanBoogie\CLDR\Cache\RuntimeCache;

use const Test\ICanBoogie\CLDR\CACHE_DIR;

class CacheCollectionTest extends TestCase
{
Expand Down
6 changes: 4 additions & 2 deletions tests/Cache/FileCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
* file that was distributed with this source code.
*/

namespace ICanBoogie\CLDR\Cache;
namespace Test\ICanBoogie\CLDR\Cache;

use ICanBoogie\CLDR\Cache;
use const ICanBoogie\CLDR\CACHE_DIR;
use ICanBoogie\CLDR\Cache\FileCache;

use const Test\ICanBoogie\CLDR\CACHE_DIR;

class FileCacheTest extends TestCase
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Cache/RedisCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
* file that was distributed with this source code.
*/

namespace ICanBoogie\CLDR\Cache;
namespace Test\ICanBoogie\CLDR\Cache;

use ICanBoogie\CLDR\Cache;
use ICanBoogie\CLDR\Cache\RedisCache;
use Redis;

class RedisCacheTest extends TestCase
Expand Down
3 changes: 2 additions & 1 deletion tests/Cache/RunTimeCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
* file that was distributed with this source code.
*/

namespace ICanBoogie\CLDR\Cache;
namespace Test\ICanBoogie\CLDR\Cache;

use ICanBoogie\CLDR\Cache;
use ICanBoogie\CLDR\Cache\RuntimeCache;

class RunTimeCacheTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Cache/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace ICanBoogie\CLDR\Cache;
namespace Test\ICanBoogie\CLDR\Cache;

use ICanBoogie\CLDR\Cache;
use function uniqid;
Expand Down
4 changes: 3 additions & 1 deletion tests/CalendarCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
* file that was distributed with this source code.
*/

namespace ICanBoogie\CLDR;
namespace Test\ICanBoogie\CLDR;

use BadMethodCallException;
use ICanBoogie\CLDR\Calendar;
use ICanBoogie\CLDR\CalendarCollection;
use ICanBoogie\OffsetNotWritable;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
Expand Down
47 changes: 25 additions & 22 deletions tests/CalendarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,33 @@
* file that was distributed with this source code.
*/

namespace ICanBoogie\CLDR;

namespace Test\ICanBoogie\CLDR;

use ICanBoogie\CLDR\Calendar;
use ICanBoogie\CLDR\DateFormatter;
use ICanBoogie\CLDR\DateTimeFormatLength;
use ICanBoogie\CLDR\DateTimeFormatter;
use ICanBoogie\CLDR\Locale;
use ICanBoogie\CLDR\TimeFormatter;
use ICanBoogie\PropertyNotDefined;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class CalendarTest extends TestCase
{
private static Calendar $calendar;
private static Calendar $sut;

public static function setupBeforeClass(): void
{
self::$calendar = locale_for('fr')->calendars['gregorian']; // @phpstan-ignore-line
self::$sut = locale_for('fr')->calendars['gregorian']; // @phpstan-ignore-line
}

#[DataProvider('provider_test_property_instanceof')]
public function test_property_instanceof(string $property, string $expected): void
{
$instance = self::$calendar->$property;
$instance = self::$sut->$property;
$this->assertInstanceOf($expected, $instance); // @phpstan-ignore-line
$this->assertSame($instance, self::$calendar->$property);
$this->assertSame($instance, self::$sut->$property);
}

/**
Expand All @@ -50,13 +56,13 @@ public static function provider_test_property_instanceof(): array
public function test_get_undefined_property(): void
{
$this->expectException(PropertyNotDefined::class);
self::$calendar->undefined_property; // @phpstan-ignore-line
self::$sut->undefined_property; // @phpstan-ignore-line
}

#[DataProvider('provide_test_access')]
public function test_access(string $key): void
{
$this->assertTrue(self::$calendar->offsetExists($key));
$this->assertTrue(self::$sut->offsetExists($key));
}

/**
Expand All @@ -82,13 +88,13 @@ public static function provide_test_access(): array
public function test_date_patterns_shortcuts(string $property, string $path): void
{
$path_parts = explode('/', $path);
$expected = self::$calendar;
$expected = self::$sut;

foreach ($path_parts as $part) {
$expected = $expected[$part];
}

$this->assertEquals(self::$calendar->$property, $expected);
$this->assertEquals(self::$sut->$property, $expected);
}

/**
Expand Down Expand Up @@ -136,25 +142,22 @@ public static function provide_test_date_patterns_shortcuts(): array

public function testFormatDateTime(): void
{
$this->assertSame(
self::$calendar->format_datetime('2018-11-24 20:12:22 UTC', DateTimeFormatLength::FULL),
"samedi 24 novembre 2018 à 20:12:22 UTC"
);
$actual = self::$sut->format_datetime('2018-11-24 20:12:22 UTC', DateTimeFormatLength::FULL);

$this->assertSame("samedi 24 novembre 2018 à 20:12:22 UTC", $actual);
}

public function testFormatDate(): void
{
$this->assertSame(
self::$calendar->format_date('2018-11-24 20:12:22 UTC', DateTimeFormatLength::LONG),
"24 novembre 2018"
);
$actual = self::$sut->format_date('2018-11-24 20:12:22 UTC', DateTimeFormatLength::LONG);

$this->assertSame("24 novembre 2018", $actual);
}

public function testFormatTime(): void
{
$this->assertSame(
self::$calendar->format_time('2018-11-24 20:12:22 UTC', DateTimeFormatLength::LONG),
"20:12:22 UTC"
);
$actual = self::$sut->format_time('2018-11-24 20:12:22 UTC', DateTimeFormatLength::LONG);

$this->assertSame("20:12:22 UTC", $actual);
}
}
3 changes: 2 additions & 1 deletion tests/ContextTransformsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
* file that was distributed with this source code.
*/

namespace ICanBoogie\CLDR;
namespace Test\ICanBoogie\CLDR;

use ICanBoogie\CLDR\ContextTransforms;
use LogicException;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
Expand Down
5 changes: 4 additions & 1 deletion tests/CurrencyCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
* file that was distributed with this source code.
*/

namespace ICanBoogie\CLDR;
namespace Test\ICanBoogie\CLDR;

use ICanBoogie\CLDR\Currency;
use ICanBoogie\CLDR\CurrencyCollection;
use ICanBoogie\CLDR\CurrencyNotDefined;
use ICanBoogie\OffsetNotWritable;
use PHPUnit\Framework\TestCase;

Expand Down
3 changes: 2 additions & 1 deletion tests/CurrencyNotDefinedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
* file that was distributed with this source code.
*/

namespace ICanBoogie\CLDR;
namespace Test\ICanBoogie\CLDR;

use Exception;
use ICanBoogie\CLDR\CurrencyNotDefined;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

Expand Down
3 changes: 2 additions & 1 deletion tests/CurrencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
* file that was distributed with this source code.
*/

namespace ICanBoogie\CLDR;
namespace Test\ICanBoogie\CLDR;

use ICanBoogie\CLDR\Currency;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

Expand Down
5 changes: 4 additions & 1 deletion tests/DateFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
* file that was distributed with this source code.
*/

namespace ICanBoogie\CLDR;
namespace Test\ICanBoogie\CLDR;

use ICanBoogie\CLDR\DateFormatter;
use ICanBoogie\CLDR\DateTimeFormatId;
use ICanBoogie\CLDR\DateTimeFormatLength;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

Expand Down
3 changes: 2 additions & 1 deletion tests/DateTimeAccessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
* file that was distributed with this source code.
*/

namespace ICanBoogie\CLDR;
namespace Test\ICanBoogie\CLDR;

use ICanBoogie\CLDR\DateTimeAccessor;
use LogicException;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
Expand Down
6 changes: 5 additions & 1 deletion tests/DateTimeFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
* file that was distributed with this source code.
*/

namespace ICanBoogie\CLDR;
namespace Test\ICanBoogie\CLDR;

use ICanBoogie\CLDR\Calendar;
use ICanBoogie\CLDR\DateTimeFormatId;
use ICanBoogie\CLDR\DateTimeFormatLength;
use ICanBoogie\CLDR\DateTimeFormatter;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

Expand Down
3 changes: 2 additions & 1 deletion tests/GitHub/UrlResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
* file that was distributed with this source code.
*/

namespace ICanBoogie\CLDR\GitHub;
namespace Test\ICanBoogie\CLDR\GitHub;

use ICanBoogie\CLDR\GitHub\UrlResolver;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

Expand Down
3 changes: 2 additions & 1 deletion tests/ListFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
* file that was distributed with this source code.
*/

namespace ICanBoogie\CLDR;
namespace Test\ICanBoogie\CLDR;

use ICanBoogie\CLDR\ListFormatter;
use ICanBoogie\CLDR\Locale\ListPattern;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
Expand Down
4 changes: 3 additions & 1 deletion tests/LocaleCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
* file that was distributed with this source code.
*/

namespace ICanBoogie\CLDR;
namespace Test\ICanBoogie\CLDR;

use BadMethodCallException;
use ICanBoogie\CLDR\Locale;
use ICanBoogie\CLDR\LocaleCollection;
use ICanBoogie\OffsetNotWritable;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
Expand Down
3 changes: 2 additions & 1 deletion tests/LocaleIdTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

namespace ICanBoogie\CLDR;
namespace Test\ICanBoogie\CLDR;

use ICanBoogie\CLDR\LocaleId;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

Expand Down
Loading

0 comments on commit 358f74f

Please sign in to comment.