nur-sery/tests/app/argsTest.php

27 lines
975 B
PHP
Raw Normal View History

2024-09-26 10:54:43 +04:00
<?php
2024-09-30 08:41:47 +04:00
namespace nur\sery\app;
2024-09-26 10:54:43 +04:00
use nulib\tests\TestCase;
2024-09-30 08:13:35 +04:00
use nur\sery\app\args;
2024-09-26 10:54:43 +04:00
class argsTest extends TestCase {
function testFrom_array() {
self::assertSame([], args::from_array(null));
self::assertSame([], args::from_array([]));
self::assertSame([], args::from_array([false]));
self::assertSame(["x"], args::from_array(["x", false]));
self::assertSame(["--opt"], args::from_array(["--opt"]));
self::assertSame(["--opt", "value"], args::from_array(["--opt", "value"]));
self::assertSame([], args::from_array(["opt" => false]));
self::assertSame(["--opt"], args::from_array(["opt" => true]));
self::assertSame(["--opt", "value"], args::from_array(["opt" => "value"]));
self::assertSame(["--opt", "42"], args::from_array(["opt" => 42]));
self::assertSame(["--opt", "1", "2", "3", "--"], args::from_array(["opt" => [1, 2, 3]]));
self::assertSame(["x", "1", "2", "3", "y"], args::from_array(["x", [1, 2, 3], "y"]));
}
}