mirror of
http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore.git
synced 2026-01-15 06:55:06 +08:00
tests(service): 添加了base64Wrapper的测试
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
vendor/
|
vendor/
|
||||||
|
.phpunit.result.cache
|
||||||
7
.idea/HDK-Core.iml
generated
7
.idea/HDK-Core.iml
generated
@@ -4,7 +4,7 @@
|
|||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="Singularity\HDK\Core\" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="Singularity\HDK\Core\" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" packagePrefix="Singularity\HDK\Test\\Core\" />
|
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" packagePrefix="Singularity\HDK\Test\Core\" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/recursion-context" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/recursion-context" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/lines-of-code" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/lines-of-code" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/type" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/type" />
|
||||||
@@ -131,6 +131,11 @@
|
|||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/code-unit-reverse-lookup" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/code-unit-reverse-lookup" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/diff" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/diff" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/swoole/ide-helper" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/swoole/ide-helper" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/vendor/pestphp/pest" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/vendor/pestphp/pest-plugin" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/vendor/filp/whoops" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/vendor/nunomaduro/collision" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/vendor/facade/ignition-contracts" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
|||||||
5
.idea/php.xml
generated
5
.idea/php.xml
generated
@@ -137,6 +137,11 @@
|
|||||||
<path value="$PROJECT_DIR$/vendor/sebastian/code-unit-reverse-lookup" />
|
<path value="$PROJECT_DIR$/vendor/sebastian/code-unit-reverse-lookup" />
|
||||||
<path value="$PROJECT_DIR$/vendor/sebastian/diff" />
|
<path value="$PROJECT_DIR$/vendor/sebastian/diff" />
|
||||||
<path value="$PROJECT_DIR$/vendor/swoole/ide-helper" />
|
<path value="$PROJECT_DIR$/vendor/swoole/ide-helper" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/pestphp/pest" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/pestphp/pest-plugin" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/filp/whoops" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/nunomaduro/collision" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/facade/ignition-contracts" />
|
||||||
</include_path>
|
</include_path>
|
||||||
</component>
|
</component>
|
||||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.0" />
|
<component name="PhpProjectSharedConfiguration" php_language_level="8.0" />
|
||||||
|
|||||||
15
phpunit.xml
15
phpunit.xml
@@ -1,9 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd">
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php"
|
||||||
<coverage/>
|
colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd">
|
||||||
<testsuites>
|
<coverage/>
|
||||||
<testsuite name="Example">
|
<testsuites>
|
||||||
<directory>./tests/Example/</directory>
|
<testsuite name="Unit">
|
||||||
</testsuite>
|
<directory>./tests/Unit/</directory>
|
||||||
</testsuites>
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|||||||
5
tests/ExampleTest.php
Normal file
5
tests/ExampleTest.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
test('example', function () {
|
||||||
|
expect(true)->toBeTrue();
|
||||||
|
});
|
||||||
45
tests/Pest.php
Normal file
45
tests/Pest.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Test Case
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The closure you provide to your test functions is always bound to a specific PHPUnit test
|
||||||
|
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
|
||||||
|
| need to change it using the "uses()" function to bind a different classes or traits.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// uses(Tests\TestCase::class)->in('Feature');
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Expectations
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When you're writing tests, you often need to check that values meet certain conditions. The
|
||||||
|
| "expect()" function gives you access to a set of "expectations" methods that you can use
|
||||||
|
| to assert different things. Of course, you may extend the Expectation API at any time.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
expect()->extend('toBeOne', function () {
|
||||||
|
return $this->toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Functions
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
|
||||||
|
| project that you don't want to repeat in every file. Here you can also expose helpers as
|
||||||
|
| global functions to help you to reduce the number of lines of code in your test files.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
function something()
|
||||||
|
{
|
||||||
|
// ..
|
||||||
|
}
|
||||||
32
tests/Unit/Base64WrapperTest.php
Normal file
32
tests/Unit/Base64WrapperTest.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Base64WrapperTest.php@HDK-Core
|
||||||
|
*
|
||||||
|
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||||
|
* Powered by PhpStorm
|
||||||
|
* Created on 2022/12/20
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Singularity\HDK\Test\Core\Unit;
|
||||||
|
|
||||||
|
use Singularity\HDK\Core\Service\Base64Wrapper;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
it('assertions base64 wrapper ENCODE', function(string $source, string $expected) {
|
||||||
|
$encoded = (new Base64Wrapper())->encode($source);
|
||||||
|
|
||||||
|
expect($expected)->toBe($encoded);
|
||||||
|
})->with([
|
||||||
|
['abc==', 'abc'],
|
||||||
|
['=ccc=', 'ccc'],
|
||||||
|
['YWJ/+j', 'YWJ_-j']
|
||||||
|
]);
|
||||||
|
|
||||||
|
it('assertions base64 wrapper DECODE', function(string $source, string $expected) {
|
||||||
|
$decoded = (new Base64Wrapper())->decode($source);
|
||||||
|
|
||||||
|
expect($expected)->toBe($decoded);
|
||||||
|
})->with([
|
||||||
|
['abc', 'abc'],
|
||||||
|
['YWJ_-j', 'YWJ/+j']
|
||||||
|
]);
|
||||||
Reference in New Issue
Block a user