Должен заменить 2 бандла моста (отдельный для request и отдельный для response)master v0.0.1
commit
8f4424ab81
@ -0,0 +1,7 @@ |
||||
.idea |
||||
/var/ |
||||
/vendor/ |
||||
###> phpunit/phpunit ### |
||||
/phpunit.xml |
||||
.phpunit.result.cache |
||||
###< phpunit/phpunit ### |
@ -0,0 +1,18 @@ |
||||
image: dh.rinsvent.ru/ci |
||||
|
||||
variables: |
||||
DOCKER_DRIVER: overlay2 |
||||
DOCKER_TLS_CERTDIR: "" |
||||
|
||||
services: |
||||
- docker:dind |
||||
|
||||
before_script: |
||||
- bash bin/docker/prepare-ci.sh |
||||
|
||||
build: |
||||
stage: build |
||||
script: |
||||
- docker login --username ${REGISTRY_USERNAME} --password ${REGISTRY_PASSWORD} dh.rinsvent.ru |
||||
- bash bin/docker/ci.sh |
||||
|
@ -0,0 +1,33 @@ |
||||
auth: |
||||
docker exec -it -u1000:1000 transformerbundle_php bash
|
||||
|
||||
auth-root: |
||||
docker exec -it transformerbundle_php bash
|
||||
|
||||
test: |
||||
bin/codecept run $p
|
||||
|
||||
coverage: |
||||
bin/codecept run --coverage --coverage-html=/app/var/temp.html
|
||||
|
||||
# make out container
|
||||
coverage-open: |
||||
google-chrome var/temp.html/index.html
|
||||
|
||||
#docker
|
||||
start: |
||||
docker-compose up -d
|
||||
stop: |
||||
docker-compose down
|
||||
pull: |
||||
docker-compose pull
|
||||
restart: stop start |
||||
restart-php: |
||||
docker-compose restart backend-php-fpm
|
||||
down-clear: |
||||
docker-compose down -v --remove-orphans
|
||||
init: down-clear pull start |
||||
|
||||
#prepare
|
||||
prepare-environment: |
||||
bash bin/docker/prepare.sh
|
@ -0,0 +1,9 @@ |
||||
#!/bin/bash |
||||
|
||||
docker-compose -f ./docker-compose-ci.yml up -d |
||||
|
||||
echo 'composer installing' |
||||
docker exec -i transformerbundle_php composer install -q |
||||
echo 'composer installed !!' |
||||
|
||||
docker exec -i transformerbundle_php vendor/bin/codecept run --coverage |
@ -0,0 +1,8 @@ |
||||
#!/bin/bash |
||||
|
||||
FULL_PROJECT_NETWORK=$(docker network ls | grep full-project) |
||||
if [ -z "$FULL_PROJECT_NETWORK" ] |
||||
then |
||||
docker network create full-project --subnet=192.168.221.0/25 |
||||
fi |
||||
|
@ -0,0 +1,16 @@ |
||||
namespace: Rinsvent\TransformerBundle\Tests |
||||
paths: |
||||
tests: tests |
||||
output: tests/_output |
||||
data: tests/_data |
||||
support: tests/_support |
||||
envs: tests/_envs |
||||
actor_suffix: Tester |
||||
extensions: |
||||
enabled: |
||||
- Codeception\Extension\RunFailed |
||||
|
||||
coverage: |
||||
enabled: true |
||||
include: |
||||
- src/* |
@ -0,0 +1,34 @@ |
||||
{ |
||||
"name": "rinsvent/transformer-bundle", |
||||
"description": "Data to dto bundle", |
||||
"license": "MIT", |
||||
"require": { |
||||
"php": "^8.0", |
||||
"ext-ctype": "*", |
||||
"ext-iconv": "*", |
||||
"ext-json": "*", |
||||
"rinsvent/transformer": "^0.0", |
||||
"symfony/http-kernel": "^5.3", |
||||
"symfony/config": "^5.3", |
||||
"symfony/dependency-injection": "^5.3" |
||||
}, |
||||
"require-dev": { |
||||
"codeception/codeception": "^4.1", |
||||
"codeception/module-phpbrowser": "^1.0.0", |
||||
"codeception/module-asserts": "^1.0.0", |
||||
"symfony/http-kernel": "^5.3", |
||||
"symfony/http-foundation": "^5.3", |
||||
"symfony/routing": "^5.3" |
||||
}, |
||||
"autoload": { |
||||
"psr-4": { |
||||
"tests\\": "tests/", |
||||
"Rinsvent\\TransformerBundle\\": "src/" |
||||
} |
||||
}, |
||||
"autoload-dev": { |
||||
"psr-4": { |
||||
"Rinsvent\\TransformerBundle\\Tests\\": "tests/" |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,15 @@ |
||||
version: '3.3' |
||||
|
||||
services: |
||||
transformerbundle_php: |
||||
image: dh.rinsvent.ru/php8dev |
||||
container_name: transformerbundle_php |
||||
volumes: |
||||
- ./:/app |
||||
environment: |
||||
USE_COMPOSER_SCRIPTS: 0 |
||||
|
||||
networks: |
||||
default: |
||||
external: |
||||
name: full-project |
@ -0,0 +1,16 @@ |
||||
version: '3.3' |
||||
|
||||
services: |
||||
transformerbundle_php: |
||||
image: dh.rinsvent.ru/php8dev |
||||
container_name: transformerbundle_php |
||||
volumes: |
||||
- ./:/app |
||||
environment: |
||||
USE_COMPOSER_SCRIPTS: 0 |
||||
PHP_IDE_CONFIG: "serverName=transformerbundle_php" |
||||
|
||||
networks: |
||||
default: |
||||
external: |
||||
name: full-project |
@ -0,0 +1,17 @@ |
||||
<?php |
||||
|
||||
namespace Rinsvent\TransformerBundle\DependencyInjection; |
||||
|
||||
use Symfony\Component\Config\FileLocator; |
||||
use Symfony\Component\DependencyInjection\ContainerBuilder; |
||||
use Symfony\Component\DependencyInjection\Extension\Extension; |
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
||||
|
||||
class TransformerExtension extends Extension |
||||
{ |
||||
public function load(array $configs, ContainerBuilder $container) |
||||
{ |
||||
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
||||
$loader->load('services.yaml'); |
||||
} |
||||
} |
@ -0,0 +1,20 @@ |
||||
<?php |
||||
|
||||
namespace Rinsvent\TransformerBundle\EventListener; |
||||
|
||||
use Rinsvent\Transformer\Resolver\TransformerResolverStorage; |
||||
use Rinsvent\TransformerBundle\Service\ServiceResolver; |
||||
use Symfony\Component\HttpKernel\Event\RequestEvent; |
||||
|
||||
class RequestListener |
||||
{ |
||||
public function __construct( |
||||
private ServiceResolver $serviceResolver |
||||
) {} |
||||
|
||||
public function onKernelRequest(RequestEvent $event) |
||||
{ |
||||
$storage = TransformerResolverStorage::getInstance(); |
||||
$storage->add(ServiceResolver::TYPE, $this->serviceResolver); |
||||
} |
||||
} |
@ -0,0 +1,18 @@ |
||||
services: |
||||
_defaults: |
||||
autoconfigure: true |
||||
public: false |
||||
autowire: true |
||||
|
||||
Rinsvent\TransformerBundle\EventListener\RequestListener: |
||||
autowire: true |
||||
tags: |
||||
- { name: kernel.event_listener, event: kernel.request, priority: 10000 } |
||||
|
||||
Rinsvent\TransformerBundle\Service\ServiceResolver: |
||||
bind: |
||||
$transformerLocator: !tagged_locator { tag: 'rinsvent.transformer.transformer', index_by: 'key', default_index_method: 'getLocatorKey' } |
||||
|
||||
_instanceof: |
||||
Rinsvent\TransformerBundle\Service\AbstractTransformer: |
||||
tags: [ 'rinsvent.transformer.transformer' ] |
@ -0,0 +1,13 @@ |
||||
<?php |
||||
|
||||
namespace Rinsvent\TransformerBundle\Service; |
||||
|
||||
use Rinsvent\Transformer\Transformer\TransformerInterface; |
||||
|
||||
abstract class AbstractTransformer implements TransformerInterface |
||||
{ |
||||
public static function getLocatorKey() |
||||
{ |
||||
return static::class; |
||||
} |
||||
} |
@ -0,0 +1,24 @@ |
||||
<?php |
||||
|
||||
namespace Rinsvent\TransformerBundle\Service; |
||||
|
||||
use Rinsvent\Transformer\Resolver\TransformerResolverInterface; |
||||
use Rinsvent\Transformer\Transformer\Meta; |
||||
use Rinsvent\Transformer\Transformer\TransformerInterface; |
||||
use Symfony\Component\DependencyInjection\ServiceLocator; |
||||
|
||||
class ServiceResolver implements TransformerResolverInterface |
||||
{ |
||||
public const TYPE = 'service'; |
||||
|
||||
public function __construct( |
||||
private ServiceLocator $transformerLocator |
||||
) { |
||||
} |
||||
|
||||
public function resolve(Meta $meta): TransformerInterface |
||||
{ |
||||
$transformerClass = $meta::class . 'Transformer'; |
||||
return $this->transformerLocator->get($transformerClass); |
||||
} |
||||
} |
@ -0,0 +1,10 @@ |
||||
<?php |
||||
|
||||
namespace Rinsvent\TransformerBundle; |
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle; |
||||
|
||||
class TransformerBundle extends Bundle |
||||
{ |
||||
|
||||
} |
@ -0,0 +1,2 @@ |
||||
* |
||||
!.gitignore |
@ -0,0 +1,46 @@ |
||||
<?php |
||||
namespace Rinsvent\TransformerBundle\Tests\Helper; |
||||
|
||||
// here you can define custom actions |
||||
// all public methods declared in helper class will be available in $I |
||||
|
||||
use Rinsvent\TransformerBundle\EventListener\RequestListener; |
||||
use Rinsvent\TransformerBundle\Tests\unit\Listener\fixtures\FillTest\Controller; |
||||
use Symfony\Component\EventDispatcher\EventDispatcher; |
||||
use Symfony\Component\HttpFoundation\Request; |
||||
use Symfony\Component\HttpFoundation\RequestStack; |
||||
use Symfony\Component\HttpFoundation\Response; |
||||
use Symfony\Component\HttpKernel\Controller\ArgumentResolver; |
||||
use Symfony\Component\HttpKernel\Controller\ControllerResolver; |
||||
use Symfony\Component\HttpKernel\EventListener\RouterListener; |
||||
use Symfony\Component\HttpKernel\HttpKernel; |
||||
use Symfony\Component\Routing\Matcher\UrlMatcher; |
||||
use Symfony\Component\Routing\RequestContext; |
||||
use Symfony\Component\Routing\Route; |
||||
use Symfony\Component\Routing\RouteCollection; |
||||
|
||||
class Unit extends \Codeception\Module |
||||
{ |
||||
public function send(Request $request): Response |
||||
{ |
||||
$routes = new RouteCollection(); |
||||
$controller = new Controller(); |
||||
$routes->add('hello', new Route('/hello/{name}', [ |
||||
'_controller' => [$controller, 'hello'] |
||||
] |
||||
)); |
||||
|
||||
$matcher = new UrlMatcher($routes, new RequestContext()); |
||||
$dispatcher = new EventDispatcher(); |
||||
$dispatcher->addSubscriber(new RouterListener($matcher, new RequestStack())); |
||||
$listener = new RequestListener(); |
||||
$dispatcher->addListener('kernel.request', [$listener, 'onKernelRequest']); |
||||
|
||||
$controllerResolver = new ControllerResolver(); |
||||
$argumentResolver = new ArgumentResolver(); |
||||
$kernel = new HttpKernel($dispatcher, $controllerResolver, new RequestStack(), $argumentResolver); |
||||
$response = $kernel->handle($request); |
||||
$response->send(); |
||||
return $response; |
||||
} |
||||
} |
@ -0,0 +1,27 @@ |
||||
<?php |
||||
|
||||
namespace Rinsvent\TransformerBundle\Tests; |
||||
|
||||
/** |
||||
* Inherited Methods |
||||
* @method void wantToTest($text) |
||||
* @method void wantTo($text) |
||||
* @method void execute($callable) |
||||
* @method void expectTo($prediction) |
||||
* @method void expect($prediction) |
||||
* @method void amGoingTo($argumentation) |
||||
* @method void am($role) |
||||
* @method void lookForwardTo($achieveValue) |
||||
* @method void comment($description) |
||||
* @method void pause() |
||||
* |
||||
* @SuppressWarnings(PHPMD) |
||||
*/ |
||||
class UnitTester extends \Codeception\Actor |
||||
{ |
||||
use _generated\UnitTesterActions; |
||||
|
||||
/** |
||||
* Define custom actions here |
||||
*/ |
||||
} |
@ -0,0 +1,2 @@ |
||||
* |
||||
!.gitignore |
@ -0,0 +1,10 @@ |
||||
# Codeception Test Suite Configuration |
||||
# |
||||
# Suite for unit or integration tests. |
||||
|
||||
actor: UnitTester |
||||
modules: |
||||
enabled: |
||||
- Asserts |
||||
- \Rinsvent\TransformerBundle\Tests\Helper\Unit |
||||
step_decorators: ~ |
Loading…
Reference in new issue