поправил косяки

Доабвил первый рабочий тест
This commit is contained in:
Rinsvent 2022-04-01 22:12:12 +07:00
parent a53c36a610
commit 60fb6855a1
2 changed files with 36 additions and 3 deletions

View File

@ -9,11 +9,14 @@ use Rinsvent\Transformer\Transformer\TransformerInterface;
class Transformer
{
public function transform(mixed $value, Meta $meta): mixed
public function transform(mixed $value, Meta $meta, array $tags = ['default']): mixed
{
$filteredTags = array_diff($tags, $meta->tags);
if (count($filteredTags) === count($tags)) {
return $value;
}
$transformer = $this->grabTransformer($meta);
$transformer->transform($value, $meta);
return $value;
return $transformer->transform($value, $meta);
}
private function grabTransformer(Meta $meta): TransformerInterface

View File

@ -0,0 +1,30 @@
<?php
namespace Rinsvent\DTO2Data\Tests\Converter;
use Rinsvent\DTO2Data\Dto2DataConverter;
use Rinsvent\DTO2Data\Tests\unit\Converter\fixtures\FillTest\Author;
use Rinsvent\DTO2Data\Tests\unit\Converter\fixtures\FillTest\Bar;
use Rinsvent\DTO2Data\Tests\unit\Converter\fixtures\FillTest\BuyRequest;
use Rinsvent\DTO2Data\Tests\unit\Converter\fixtures\FillTest\Collection;
use Rinsvent\DTO2Data\Tests\unit\Converter\fixtures\FillTest\CollectionItem;
use Rinsvent\DTO2Data\Tests\unit\Converter\fixtures\FillTest\HelloRequest;
use Rinsvent\DTO2Data\Tests\unit\Converter\fixtures\FillTest\HelloSchema;
use Rinsvent\DTO2Data\Tests\unit\Converter\fixtures\FillTest\UUID;
use Rinsvent\Transformer\Transformer;
class FillTest extends \Codeception\Test\Unit
{
/**
* @var \UnitTester
*/
protected $tester;
// tests
public function testSuccessFillRequestData()
{
$t = new Transformer();
$actual = $t->transform(' asdas ', new Transformer\Trim());
$this->assertEquals('asdas', $actual);
}
}