Page MenuHomeDevCentral

No OneTemporary

diff --git a/composer.json b/composer.json
index 293dbe3..f0497248 100644
--- a/composer.json
+++ b/composer.json
@@ -1,27 +1,27 @@
{
"name": "keruald/omnitools",
"description": "Utilities classes",
"type": "library",
"license": "BSD-2-Clause",
"authors": [
{
"name": "Sébastien Santoro",
"email": "dereckson@espace-win.org"
}
],
"autoload": {
"psr-4": {
"Keruald\\OmniTools\\": "src/",
"Keruald\\OmniTools\\Tests\\": "tests/"
}
},
"require": {
"ext-intl": "*"
},
"require-dev": {
"nasqueron/codestyle": "^0.1.2",
"phan/phan": "^5.3.1",
- "phpunit/phpunit": "^10.2",
+ "phpunit/phpunit": "^12.4",
"squizlabs/php_codesniffer": "^4.0.0"
}
}
diff --git a/tests/HTTP/URLTest.php b/tests/HTTP/URLTest.php
index f7fce5d..059916d 100644
--- a/tests/HTTP/URLTest.php
+++ b/tests/HTTP/URLTest.php
@@ -1,83 +1,83 @@
<?php
declare(strict_types=1);
namespace Keruald\OmniTools\Tests\HTTP;
use Keruald\OmniTools\HTTP\URL;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class URLTest extends TestCase {
#[DataProvider('provideURLsAndComponents')]
- public function testGetDomain ($url, $expectedDomain) : void {
+ public function testGetDomain ($url, $expectedDomain, $_, $__, $___ = null) : void {
$url = new URL($url);
$this->assertEquals($expectedDomain, $url->getDomain());
}
#[DataProvider('provideURLsAndComponents')]
- public function testGetProtocol ($url, $_, $expectedProtocol) : void {
+ public function testGetProtocol ($url, $_, $expectedProtocol, $__, $___ = null) : void {
$url = new URL($url);
$this->assertEquals($expectedProtocol, $url->getProtocol());
}
#[DataProvider('provideURLsAndComponents')]
- public function testGetQuery ($url, $_, $__, $expectedQuery) : void {
+ public function testGetQuery ($url, $_, $__, $expectedQuery, $___ = null) : void {
$url = new URL($url);
$this->assertEquals($expectedQuery, $url->getQuery());
}
public function testSetProtocol () : void {
$url = new URL("https://acme.tld/foo");
$url->setProtocol("xizzy");
$this->assertEquals("xizzy", $url->getProtocol());
}
public function testSetDomain () : void {
$url = new URL("https://acme.tld/foo");
$url->setDomain("xizzy");
$this->assertEquals("xizzy", $url->getDomain());
}
public function testSetQuery () : void {
$url = new URL("https://acme.tld/foo");
$url->setQuery("/xizzy");
$this->assertEquals("/xizzy", $url->getQuery());
}
public function testSetQueryWithSlashForgotten () : void {
$url = new URL("https://acme.tld/foo");
$url->setQuery("xizzy");
$this->assertEquals("/xizzy", $url->getQuery());
}
#[DataProvider('provideURLsAndComponents')]
public function testCompose ($url, $domain, $protocol, $query,
$expectedUrl = null) {
$this->assertEquals(
$expectedUrl ?? $url,
URL::compose($protocol, $domain, $query)->__toString()
);
}
public static function provideURLsAndComponents () : iterable {
// base URL, domain, protocol, query[, expected URL]
// When omitted, the expected URL is the base URL.
yield ["http://foo/bar", "foo", "http", "/bar"];
yield ["https://xn--dghrefn-mxa.nasqueron.org/", "dæghrefn.nasqueron.org", "https", "/"];
yield ["://foo/bar", "foo", "", "/bar"];
yield ["/bar", "", "", "/bar"];
yield ["http://foo/bar%20quux", "foo", "http", "/bar quux"];
yield ["https://foo/", "foo", "https", "/"];
yield ["https://foo", "foo", "https", "/", "https://foo/"];
}
}
diff --git a/tests/Strings/Multibyte/StringUtilitiesTest.php b/tests/Strings/Multibyte/StringUtilitiesTest.php
index 77c8092..3885b83 100644
--- a/tests/Strings/Multibyte/StringUtilitiesTest.php
+++ b/tests/Strings/Multibyte/StringUtilitiesTest.php
@@ -1,116 +1,118 @@
<?php
declare(strict_types=1);
namespace Keruald\OmniTools\Tests\Strings\Multibyte;
use Keruald\OmniTools\Strings\Multibyte\StringUtilities;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class StringUtilitiesTest extends TestCase {
///
/// Tests
///
#[DataProvider('providePadding')]
public function testPad (
string $expected,
string $input, int $padLength, string $padString, int $padType
) : void {
$paddedString = StringUtilities::pad(
$input, $padLength, $padString, $padType, "UTF-8"
);
$this->assertEquals($expected, $paddedString);
}
public function testPadWithDefaultArguments () : void {
$this->assertEquals("foo ", StringUtilities::pad("foo", 4));
$this->assertEquals("foo_", StringUtilities::pad("foo", 4, '_'));
$this->assertEquals("_foo", StringUtilities::pad("foo", 4, '_', STR_PAD_LEFT));
}
public function testSupportedEncoding () : void {
$this->assertTrue(StringUtilities::isSupportedEncoding("UTF-8"));
$this->assertFalse(StringUtilities::isSupportedEncoding("notexisting"));
}
public function testStartsWith () : void {
$this->assertTrue(StringUtilities::startsWith("foo", "fo"));
$this->assertTrue(StringUtilities::startsWith("foo", ""));
$this->assertTrue(StringUtilities::startsWith("foo", "foo"));
$this->assertFalse(StringUtilities::startsWith("foo", "bar"));
}
public function testEndsWith () : void {
$this->assertTrue(StringUtilities::endsWith("foo", "oo"));
$this->assertTrue(StringUtilities::endsWith("foo", ""));
$this->assertTrue(StringUtilities::endsWith("foo", "foo"));
$this->assertFalse(StringUtilities::endsWith("foo", "oO"));
$this->assertFalse(StringUtilities::endsWith("foo", "bar"));
}
#[DataProvider('provideBase64')]
public function testEncodeInBase64 (string $decoded, string $encoded) : void {
$actual = StringUtilities::encodeInBase64($decoded);
$this->assertEquals($encoded, $actual);
}
#[DataProvider('provideBase64')]
public function testDecodeFromBase64 (string $decoded, string $encoded) : void {
$actual = StringUtilities::decodeFromBase64($encoded);
$this->assertEquals($decoded, $actual);
}
///
/// Data providers
///
public static function providePadding () : iterable {
// Tests from http://3v4l.org/UnXTF
// http://web.archive.org/web/20150711100913/http://3v4l.org/UnXTF
yield ['àèòàFOOàèòà', "FOO", 11, "àèò", STR_PAD_BOTH];
yield ['àèòFOOàèòà', "FOO", 10, "àèò", STR_PAD_BOTH];
yield ['àèòBAAZàèòà', "BAAZ", 11, "àèò", STR_PAD_BOTH];
yield ['àèòBAAZàèò', "BAAZ", 10, "àèò", STR_PAD_BOTH];
yield ['FOOBAR', "FOOBAR", 6, "àèò", STR_PAD_BOTH];
yield ['FOOBAR', "FOOBAR", 1, "àèò", STR_PAD_BOTH];
yield ['FOOBAR', "FOOBAR", 0, "àèò", STR_PAD_BOTH];
yield ['FOOBAR', "FOOBAR", -10, "àèò", STR_PAD_BOTH];
yield ['àèòàèòàèFOO', "FOO", 11, "àèò", STR_PAD_LEFT];
yield ['àèòàèòàFOO', "FOO", 10, "àèò", STR_PAD_LEFT];
yield ['àèòàèòàBAAZ', "BAAZ", 11, "àèò", STR_PAD_LEFT];
yield ['àèòàèòBAAZ', "BAAZ", 10, "àèò", STR_PAD_LEFT];
yield ['FOOBAR', "FOOBAR", 6, "àèò", STR_PAD_LEFT];
yield ['FOOBAR', "FOOBAR", 1, "àèò", STR_PAD_LEFT];
yield ['FOOBAR', "FOOBAR", 0, "àèò", STR_PAD_LEFT];
yield ['FOOBAR', "FOOBAR", -10, "àèò", STR_PAD_LEFT];
yield ['FOOàèòàèòàè', "FOO", 11, "àèò", STR_PAD_RIGHT];
yield ['FOOàèòàèòà', "FOO", 10, "àèò", STR_PAD_RIGHT];
yield ['BAAZàèòàèòà', "BAAZ", 11, "àèò", STR_PAD_RIGHT];
yield ['BAAZàèòàèò', "BAAZ", 10, "àèò", STR_PAD_RIGHT];
yield ['FOOBAR', "FOOBAR", 6, "àèò", STR_PAD_RIGHT];
yield ['FOOBAR', "FOOBAR", 1, "àèò", STR_PAD_RIGHT];
yield ['FOOBAR', "FOOBAR", 0, "àèò", STR_PAD_RIGHT];
yield ['FOOBAR', "FOOBAR", -10, "àèò", STR_PAD_RIGHT];
}
public static function provideBase64 () : iterable {
- yield ['foo', 'Zm9v', "This is the regular base test without any exception."];
- yield ['', '', "An empty string should remain an empty string."];
- yield [
+ yield "This is the regular base test without any exception." => ['foo', 'Zm9v'];
+
+ yield "An empty string should remain an empty string." => ['', ''];
+
+ yield "No padding should be used." => [
"J'ai fait mes 60 prières par terre dans la poudrière.",
'SidhaSBmYWl0IG1lcyA2MCBwcmnDqHJlcyBwYXIgdGVycmUgZGFucyBsYSBwb3VkcmnDqHJlLg',
- "No padding should be used."
];
- yield [
- "àèòàFOOàèòà", "w6DDqMOyw6BGT0_DoMOow7LDoA",
- "Slashes / should be replaced by underscores _."
+
+ yield "Slashes / should be replaced by underscores _." => [
+ "àèòàFOOàèòà",
+ "w6DDqMOyw6BGT0_DoMOow7LDoA",
];
}
}

File Metadata

Mime Type
text/x-diff
Expires
Wed, Oct 14, 21:11 (1 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4185855
Default Alt Text
(9 KB)

Event Timeline