10 Commits

Author SHA1 Message Date
Your Name
47dac3fa50 configuring infection 2024-10-19 18:49:51 +03:00
Your Name
06bdf2c9c2 create Action class 2024-10-19 18:40:14 +03:00
Your Name
b9541200da added PHP_VERSION for environment 2024-10-19 18:39:10 +03:00
Your Name
5eb9495529 update MapperTypeTest 2024-10-19 18:38:33 +03:00
Your Name
53455912a8 fixed error 2024-10-19 18:38:06 +03:00
Your Name
705a50d681 creating configuration and type casting 2024-10-18 22:27:29 +03:00
Your Name
7744d22039 added symfony/var-dumper 2024-10-18 19:43:15 +03:00
Your Name
1fbc211eed updating structure 2024-10-13 19:18:28 +03:00
A.Gudko
431cd5ca43 update php version 2024-08-29 22:16:57 +03:00
Your Name
af9260a35c updating structure 2024-08-25 18:34:01 +03:00
39 changed files with 8680 additions and 65 deletions

View File

@@ -0,0 +1,4 @@
.idea
.github
var
vendor

20
.editorconfig Normal file
View File

@@ -0,0 +1,20 @@
# editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.yml]
indent_size = 2
[Makefile]
indent_style = tab

7
.env.dist Normal file
View File

@@ -0,0 +1,7 @@
PHP_VERSION="8.3"
GITEA_INSTANCE_BASE_URL="https://gitea.example.com"
GITEA_ACCESS_TOKEN="access_token"
GITEA_OWNER="owner"
GITEA_REPOSITORY="repository"
GITEA_PACKAGE_REGISTRY="composer"

View File

@@ -1,5 +1,7 @@
PHP_VERSION="8.3"
GITEA_INSTANCE_BASE_URL="https://gitea.example.com"
GITEA_ACCESS_TOKEN="access_token"
GITEA_OWNER="owner"
GITEA_REPOSITORY="repository"
GITEA_PACKAGE_REGISTRY="composer"
GITEA_PACKAGE_REGISTRY="composer"

26
.gitattributes vendored Normal file
View File

@@ -0,0 +1,26 @@
* text=auto
AUTHORS text
CHANGELOG text
CHANGES text
CONTRIBUTING text
COPYING text
LICENSE text
NEWS text
.editorconfig text
.gitattributes text
.gitconfig text
.env text
.env.example text
.env.ci text
.gitignore text
.dockerignore text
Dockerfile text
Makefile text
composer.json text eol=lf
*.md text diff=markdown
*.php text diff=php
*.sh text eol=lf
*.yml text
*.json text

View File

@@ -1,24 +0,0 @@
on:
issues:
types: [opened, edited, reopened]
issue_comment:
types: [created, edited]
jobs:
send_telegram_message:
name: send telegram message
runs-on: ubuntu-latest
steps:
- name: send telegram message
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
Gitea. Creating new issue
Author: ${{ gitea.actor }}
Repository: ${{ gitea.repository }}
See changes: https://gitea.com/${{ gitea.repository }}/issues/${{ gitea.event.issue.number }}

197
.github/workflows/tests.yml vendored Normal file
View File

@@ -0,0 +1,197 @@
name: tests
on:
pull_request: ~
push:
branches: ['*.*.*']
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
jobs:
docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- run: cp .env.dist .env
- uses: falti/dotenv-action@v1
id: dotenv
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
build-args: |
PHP_VERSION=${{ steps.dotenv.outputs.PHP_VERSION }}
push: false
composer-validate:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 8.3
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
- run: composer validate
composer-normalize:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 8.3
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
- uses: ramsey/composer-install@v3
with:
composer-options: --optimize-autoloader
- run: composer normalize
composer-require-checker:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 8.3
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
- uses: ramsey/composer-install@v3
with:
composer-options: --optimize-autoloader
- run: composer require-checker
composer-unused:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 8.3
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
- uses: ramsey/composer-install@v3
with:
composer-options: --optimize-autoloader
- run: composer unused
linter:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 8.3
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2, cs2pr
coverage: none
- uses: ramsey/composer-install@v3
with:
composer-options: --optimize-autoloader
- run: composer php-cs-fixer -- --dry-run --diff --format=checkstyle --ansi | cs2pr
refactoring:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 8.3
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
- uses: ramsey/composer-install@v3
with:
composer-options: --optimize-autoloader
- run: composer rector -- --dry-run
static-analysis:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 8.3
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
- uses: ramsey/composer-install@v3
with:
composer-options: --optimize-autoloader
- run: composer psalm -- --php-version=${{ matrix.php }} --stats --output-format=github --shepherd
unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 8.3
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: pcov
- uses: ramsey/composer-install@v3
with:
composer-options: --optimize-autoloader
# - run: composer test -- --colors=always --order-by=random --coverage-clover coverage.xml
- run: composer phpunit
mutation-tests:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 8.3
steps:
- uses: actions/checkout@v4
with:
ref: ${{env.BRANCH}}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: pcov
- uses: ramsey/composer-install@v3
with:
composer-options: --optimize-autoloader
- run: composer infection

3
.gitignore vendored
View File

@@ -1,2 +1,3 @@
.idea
/.env
.env
vendor

27
.php-cs-fixer.dist.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PHPyh\CodingStandard\PhpCsFixerCodingStandard;
$finder = Finder::create()
->in([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->append([
__FILE__,
])
->notPath([
'benchmark.php',
]);
$config = (new Config())
->setFinder($finder)
->setCacheFile(__DIR__ . '/var/.php-cs-fixer.cache');
(new PhpCsFixerCodingStandard())->applyTo($config);
return $config;

View File

@@ -1,4 +1,11 @@
FROM rosven9856/php:8.3.10-1
ARG PHP_VERSION=8.3
FROM rosven9856/php:$PHP_VERSION
RUN apk add --update --no-cache --virtual .build-deps ${PHPIZE_DEPS} \
&& pecl install pcov \
&& docker-php-ext-enable pcov \
&& apk del .build-deps
RUN addgroup -g 1000 --system php
RUN adduser -G php --system -D -s /bin/sh -u 1000 php
@@ -6,17 +13,18 @@ RUN adduser -G php --system -D -s /bin/sh -u 1000 php
RUN chown php:php /home/php
RUN chown php:php /usr/local/bin/composer
RUN mkdir /var/src
RUN chown -R php:php /var/src
RUN mkdir /usr/bin/app
RUN chown -R php:php /usr/bin/app
WORKDIR /var/src
COPY . /usr/bin/app
WORKDIR /usr/bin/app
COPY ./src /var/src
ENV GITHUB_WORKSPACE=/usr/bin/app
RUN composer install
VOLUME ["/usr/bin/app"]
USER php
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php", "-f", "/usr/bin/app/app.php"]

View File

@@ -19,4 +19,28 @@ This action will update the package version in the Gitea system using the API an
gitea_access_token: "${{ secrets._GITEA_ACCESS_TOKEN }}"
gitea_owner: "owner"
gitea_repository: "repository"
gitea_package_registry: "composer"
gitea_package_registry: "composer"
```
## Developing
build
```shell
docker build . --build-arg=PHP_VERSION=8.3 -t=gitea-package-action
```
initialization
```shell
docker run --rm -v .:/usr/bin/app gitea-package-action composer install
```
running
```shell
docker run --rm -v .:/usr/bin/app gitea-package-action php app.php
```
testing
```shell
docker run --rm -v .:/usr/bin/app gitea-package-action composer tests
```

12
action.Dockerfile Normal file
View File

@@ -0,0 +1,12 @@
ARG PHP_VERSION=8.3
FROM rosven9856/php:$PHP_VERSION
COPY . /usr/bin/app
WORKDIR /usr/bin/app
RUN composer install --optimize-autoloader
VOLUME ["/usr/bin/app"]
ENTRYPOINT ["php", "-f", "/usr/bin/app/app.php"]

View File

@@ -18,7 +18,7 @@ inputs:
required: true
runs:
using: "docker"
image: "Dockerfile"
image: "action.Dockerfile"
args:
- ${{ inputs.gitea_instance_base_url }}
- ${{ inputs.gitea_access_token }}
@@ -27,4 +27,4 @@ runs:
- ${{ inputs.gitea_package_registry }}
branding:
icon: 'package'
color: 'green'
color: 'green'

View File

@@ -1,11 +1,38 @@
<?php
declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php';
use App\Action;
use App\Configuration\Configuration;
use App\Casting\MapperType;
\define('RED', "\033[0;31m");
\define('GREEN', "\033[1;32m");
\define('YELLOW', "\033[1;33m");
\define('LITE_CYAN', "\e[96m");
\define('NC', "\033[0m");
try {
$configuration = (new Configuration())
->set('base_url', \getenv('gitea_instance_base_url'))
->set('access_token', \getenv('gitea_access_token'))
->set('owner', \getenv('gitea_owner'))
->set('owner', \getenv('gitea_owner'))
->set('repository', \getenv('gitea_repository'))
->set('package_registry', \getenv('gitea_package_registry'))
;
(new Action($configuration))->run();
} catch (Exception) {
// echo 'Error: ' . $e->getMessage() . "\n" . 'Trace: ' . $e->getTraceAsString();
}
function sendRequest ($method = 'GET', $endpoint = '', $data = []): array {
if (!\extension_loaded('curl')) {
@@ -222,4 +249,4 @@ try {
}
showTerminalMessage("\r\n");
showTerminalMessage('SUCCESS!', GREEN);
showTerminalMessage('SUCCESS!', GREEN);

View File

@@ -1,19 +0,0 @@
services:
php-fpm:
container_name: php-fpm
build:
context: ./
dockerfile: Dockerfile
environment:
gitea_instance_base_url: ${GITEA_INSTANCE_BASE_URL}
gitea_access_token: ${GITEA_ACCESS_TOKEN}
gitea_owner: ${GITEA_OWNER}
gitea_repository: ${GITEA_REPOSITORY}
gitea_package_registry: ${GITEA_PACKAGE_REGISTRY}
volumes:
- ./src:/var/src
networks:
- bridge
networks:
bridge:
driver: bridge

View File

@@ -0,0 +1,16 @@
{
"symbol-whitelist" : [],
"php-core-extensions" : [
"Core",
"date",
"json",
"hash",
"pcre",
"Phar",
"Reflection",
"SPL",
"random",
"standard"
],
"scan-files" : []
}

68
composer.json Normal file
View File

@@ -0,0 +1,68 @@
{
"name": "rosven9856/gitea-package-action",
"description": "",
"license": "MIT",
"authors": [
{
"name": "rosven9856",
"email": "rosven9856@gmail.com"
}
],
"require": {
"php": "^8.3",
"ext-curl": "*"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.42",
"friendsofphp/php-cs-fixer": "^3.57",
"icanhazstring/composer-unused": "^0.8.11",
"infection/infection": "^0.27.11",
"maglnet/composer-require-checker": "^4.11",
"phpunit/phpunit": "^10.4.2",
"phpyh/coding-standard": "^2.6",
"psalm/plugin-phpunit": "^0.18.4",
"rector/rector": "^1.1",
"symfony/var-dumper": "^7.1",
"vimeo/psalm": "^5.24"
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\": "tests/"
}
},
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true,
"infection/extension-installer": true
},
"sort-packages": true,
"sort-scripts": false
},
"scripts": {
"infection": "infection --threads=max --show-mutations",
"normalize": "composer normalize --dry-run --diff --ansi",
"php-cs-fixer": "php-cs-fixer fix --diff --verbose",
"phpunit": "phpunit --colors=always --order-by=random",
"psalm": "psalm --show-info=true --no-diff",
"rector": "rector process",
"require-checker": "composer-require-checker check --config-file=composer-require-checker.json composer.json",
"tests": [
"@validate",
"@normalize",
"@require-checker",
"@unused",
"composer php-cs-fixer -- --dry-run --diff --format=checkstyle --ansi",
"composer rector -- --dry-run",
"composer psalm -- --stats --shepherd",
"@phpunit",
"@infection"
],
"unused": "composer-unused --excludePackage=ext-curl",
"validate": "composer validate --strict --ansi"
}
}

7801
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +0,0 @@
#!/bin/sh
php /var/src/app.php

19
infection.json5.dist Normal file
View File

@@ -0,0 +1,19 @@
{
"$schema": "vendor/infection/infection/resources/schema.json",
"source": {
"directories": [
"src"
]
},
"logs": {
"text": "var/infection.log",
"stryker": {
"report": "/^\\d+\\.\\d+\\.x$/"
},
},
"tmpDir": "var",
"minCoveredMsi": 20,
"mutators": {
"@default": true
}
}

27
phpunit.xml.dist Normal file
View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
cacheDirectory="var/phpunit"
executionOrder="depends,defects"
requireCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true"
>
<php>
<ini name="display_errors" value="1"/>
<ini name="error_reporting" value="-1"/>
</php>
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory>src</directory>
</include>
</source>
</phpunit>

75
psalm.xml.dist Normal file
View File

@@ -0,0 +1,75 @@
<?xml version="1.0"?>
<psalm
cacheDirectory="var/psalm"
checkForThrowsDocblock="true"
checkForThrowsInGlobalScope="true"
disableSuppressAll="true"
ensureArrayStringOffsetsExist="true"
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="true"
findUnusedPsalmSuppress="true"
findUnusedVariablesAndParams="true"
memoizeMethodCallResults="true"
reportMixedIssues="true"
sealAllMethods="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<enableExtensions>
<extension name="dom"/>
</enableExtensions>
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
<projectFiles>
<file name="app.php"/>
<directory name="src"/>
<directory name="tests"/>
<ignoreFiles>
<directory name="var"/>
<directory name="vendor"/>
<file name="tests/benchmark.php"/>
</ignoreFiles>
</projectFiles>
<ignoreExceptions>
<classAndDescendants name="LogicException"/>
<classAndDescendants name="RuntimeException"/>
<classAndDescendants name="ReflectionException"/>
</ignoreExceptions>
<issueHandlers>
<MissingThrowsDocblock>
<errorLevel type="suppress">
<directory name="tests"/>
</errorLevel>
</MissingThrowsDocblock>
<MixedAssignment errorLevel="suppress"/>
<PossiblyUnusedMethod>
<errorLevel type="suppress">
<directory name="tests"/>
</errorLevel>
</PossiblyUnusedMethod>
<UnusedMethodCall>
<errorLevel type="suppress">
<directory name="tests"/>
</errorLevel>
</UnusedMethodCall>
</issueHandlers>
<forbiddenFunctions>
<function name="dd"/>
<function name="die"/>
<function name="dump"/>
<function name="echo"/>
<function name="eval"/>
<function name="exit"/>
<function name="print"/>
<function name="sleep"/>
<function name="usleep"/>
</forbiddenFunctions>
</psalm>

20
rector.php Normal file
View File

@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\DowngradeLevelSetList;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->parallel();
$rectorConfig->cacheDirectory(__DIR__ . '/var/rector');
$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_83,
// DowngradeLevelSetList::DOWN_TO_PHP_81,
]);
};

0
src/.gitkeep Normal file
View File

37
src/Action.php Normal file
View File

@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace App;
use App\Configuration\Configuration;
final class Action
{
private Configuration $configuration;
public function __construct(Configuration $configuration)
{
$this->configuration = $configuration;
return $this;
}
public function run(): void
{
$this->checkExtensions();
$this->checkConfiguration();
// $this->configuration->getCastingType('param', MapperType::STRING)->getAsCasting()
}
private function checkExtensions(): void
{
}
private function checkConfiguration(): void
{
}
}

10
src/Casting/Casting.php Normal file
View File

@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace App\Casting;
interface Casting
{
public function getAsCasting(): mixed;
}

View File

@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace App\Casting;
use App\Casting\Type\IntegerType;
use App\Casting\Type\StringType;
use App\Casting\Type\Type;
use App\Exception\Casting\TypeNotFountException;
final readonly class MapperType
{
public const string STRING = 'string';
public const string INTEGER = 'integer';
public const string INT = 'int';
private const array MAP = [
self::STRING => StringType::class,
self::INTEGER => IntegerType::class,
self::INT => IntegerType::class,
];
private string $class;
/**
* @throws TypeNotFountException
*/
public function __construct(string $type)
{
if (!isset(self::MAP[$type])) {
throw new TypeNotFountException(
\sprintf('Casting type "%s" is not found.', $type),
);
}
$this->class = self::MAP[$type];
}
/**
* @return mixed
*/
public function create(mixed $value): Type
{
return new $this->class($value);
}
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace App\Casting\Type;
use App\Casting\Casting;
abstract class AbstractType implements Type, Casting
{
public function __construct(protected mixed $value) {}
#[\Override]
final public function getValue()
{
return $this->value;
}
#[\Override]
abstract public function getAsCasting(): mixed;
}

View File

@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace App\Casting\Type;
final class IntegerType extends AbstractType
{
#[\Override]
public function getAsCasting(): int
{
return (int) $this->getValue();
}
}

View File

@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace App\Casting\Type;
final class StringType extends AbstractType
{
#[\Override]
public function getAsCasting(): string
{
return (string) $this->getValue();
}
}

10
src/Casting/Type/Type.php Normal file
View File

@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace App\Casting\Type;
interface Type
{
public function getValue();
}

View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace App\Configuration;
use App\Casting\MapperType;
use App\Casting\Type\Type;
use App\Exception\Casting\TypeNotFountException;
final class Configuration
{
public array $options = [];
public function __construct()
{
return $this;
}
public function set(string $key, mixed $value): self
{
$this->options[$key] = $value;
return $this;
}
public function get(string $key): mixed
{
return $this->options[$key] ?? null;
}
/**
* @throws TypeNotFountException
*/
public function getCastingType(string $key, string $type): Type
{
return (new MapperType($type))->create($this->get($key));
}
}

View File

@@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace App\Exception\Casting;
use App\Exception\Exception;
final class TypeNotFountException extends Exception {}

View File

@@ -0,0 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Exception;
class Exception extends \Exception {}

View File

@@ -1,5 +0,0 @@
{
"require": {
"ext-curl": "*"
}
}

View File

@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace App\Casting;
use App\Casting\Type\IntegerType;
use App\Casting\Type\StringType;
use App\Exception\Casting\TypeNotFountException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
#[CoversClass(MapperType::class)]
final class MapperTypeTest extends TestCase
{
public function testGetStringType(): void
{
$type = (new MapperType(MapperType::STRING))->create('value');
self::assertInstanceOf(
StringType::class,
$type,
);
}
public function testGetIntegerType(): void
{
$type = (new MapperType(MapperType::INTEGER))->create(1);
self::assertInstanceOf(
IntegerType::class,
$type,
);
}
public function testGetIntType(): void
{
$type = (new MapperType(MapperType::INT))->create(1);
self::assertInstanceOf(
IntegerType::class,
$type,
);
}
public function testTypeNotFountException(): void
{
self::expectException(TypeNotFountException::class);
(new MapperType('type-exception'))->create('value');
}
}

View File

@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace App\Configuration;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
#[CoversClass(Configuration::class)]
final class ConfigurationTest extends TestCase
{
public function testUseConfiguration(): void
{
$configuration = new Configuration();
$configuration->set('test-option', 'test-value');
self::assertEquals(
$configuration->get('test-option'),
'test-value',
);
}
}

1
tests/benchmark.php Normal file
View File

@@ -0,0 +1 @@
<?php

2
var/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*
!.gitignore