1
0
mirror of synced 2024-11-28 15:46:04 +03:00

Update code base

This commit is contained in:
Кривич Сергей 2022-07-20 14:38:42 +03:00
parent 22c3971bc8
commit 897df39d96
25 changed files with 28 additions and 359 deletions

View File

@ -5,16 +5,8 @@ namespace RetailCrm\ServiceBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
* Class Configuration
*
* @package RetailCrm\ServiceBundle\DependencyInjection
*/
class Configuration implements ConfigurationInterface class Configuration implements ConfigurationInterface
{ {
/**
* {@inheritdoc }
*/
public function getConfigTreeBuilder(): TreeBuilder public function getConfigTreeBuilder(): TreeBuilder
{ {
$treeBuilder = new TreeBuilder('retail_crm_service'); $treeBuilder = new TreeBuilder('retail_crm_service');

View File

@ -14,17 +14,8 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Reference;
/**
* Class RetailCrmServiceExtension
*
* @package RetailCrm\ServiceBundle\DependencyInjection
*/
class RetailCrmServiceExtension extends Extension class RetailCrmServiceExtension extends Extension
{ {
/**
* @param array $configs
* @param ContainerBuilder $container
*/
public function load(array $configs, ContainerBuilder $container): void public function load(array $configs, ContainerBuilder $container): void
{ {
$configuration = $this->getConfiguration($configs, $container); $configuration = $this->getConfiguration($configs, $container);

View File

@ -5,33 +5,18 @@ namespace RetailCrm\ServiceBundle\Exceptions;
use InvalidArgumentException; use InvalidArgumentException;
use Throwable; use Throwable;
/**
* Class InvalidRequestArgumentException
*
* @package RetailCrm\ServiceBundle\Exceptions
*/
class InvalidRequestArgumentException extends InvalidArgumentException class InvalidRequestArgumentException extends InvalidArgumentException
{ {
private $validateErrors; private $validateErrors;
/** public function __construct(string $message = "", int $code = 0, array $errors = [], Throwable $previous = null)
* InvalidRequestArgumentException constructor.
* @param string $message
* @param int $code
* @param array $errors
* @param Throwable|null $previous
*/
public function __construct($message = "", $code = 0, iterable $errors = [], Throwable $previous = null)
{ {
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
$this->validateErrors = $errors; $this->validateErrors = $errors;
} }
/** public function getValidateErrors(): array
* @return iterable
*/
public function getValidateErrors(): iterable
{ {
return $this->validateErrors; return $this->validateErrors;
} }

View File

@ -2,91 +2,54 @@
namespace RetailCrm\ServiceBundle\Messenger; namespace RetailCrm\ServiceBundle\Messenger;
/**
* Class Message
*
* @package RetailCrm\ServiceBundle\Messenger
*/
abstract class CommandMessage abstract class CommandMessage
{ {
/** @var string */ protected string $commandName;
protected $commandName;
/** @var array */ protected array $options = [];
protected $options = [];
/** @var array */ protected array $arguments = [];
protected $arguments = [];
/**
* @return string
*/
public function getCommandName(): string public function getCommandName(): string
{ {
return $this->commandName; return $this->commandName;
} }
/**
* @param string $commandName
*/
public function setCommandName(string $commandName): void public function setCommandName(string $commandName): void
{ {
$this->commandName = $commandName; $this->commandName = $commandName;
} }
/**
* @return array
*/
public function getOptions(): array public function getOptions(): array
{ {
return $this->options; return $this->options;
} }
/**
* @param array $options
*/
public function setOptions(array $options): void public function setOptions(array $options): void
{ {
$this->options = $options; $this->options = $options;
} }
/**
* @return array
*/
public function getArguments(): array public function getArguments(): array
{ {
return $this->arguments; return $this->arguments;
} }
/**
* @param array $arguments
*/
public function setArguments(array $arguments): void public function setArguments(array $arguments): void
{ {
$this->arguments = $arguments; $this->arguments = $arguments;
} }
/**
* @param string $key
* @param string $value
*/
public function addOption(string $key, string $value): void public function addOption(string $key, string $value): void
{ {
$this->options[$key] = $value; $this->options[$key] = $value;
} }
/**
* @param string $key
* @param string $value
*/
public function addArgument(string $key, string $value): void public function addArgument(string $key, string $value): void
{ {
$this->arguments[$key] = $value; $this->arguments[$key] = $value;
} }
/**
* @return array
*/
public function getFormattedOptions(): array public function getFormattedOptions(): array
{ {
$options = []; $options = [];
@ -97,11 +60,6 @@ abstract class CommandMessage
return $options; return $options;
} }
/**
* For lockable message
*
* @return array
*/
public function __serialize(): array public function __serialize(): array
{ {
return [ return [

View File

@ -6,31 +6,13 @@ use RetailCrm\ServiceBundle\Messenger\MessageHandler\JobRunner;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface; use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
use Exception; use Exception;
/**
* Class MessageHandler
*
* @package RetailCrm\ServiceBundle\Messenger
*/
class MessageHandler implements MessageHandlerInterface class MessageHandler implements MessageHandlerInterface
{ {
/** public function __construct(private JobRunner $runner)
* @var JobRunner
*/
private $runner;
/**
* CommandQueueHandler constructor.
*
* @param JobRunner $runner
*/
public function __construct(JobRunner $runner)
{ {
$this->runner = $runner;
} }
/** /**
* @param CommandMessage $message
*
* @throws Exception * @throws Exception
*/ */
public function __invoke(CommandMessage $message): void public function __invoke(CommandMessage $message): void

View File

@ -9,38 +9,17 @@ use Symfony\Component\Process\Exception\ProcessTimedOutException;
use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
/**
* Class InNewProcessRunner
*
* @package RetailCrm\ServiceBundle\Messenger\MessageHandler
*/
class InNewProcessRunner implements JobRunner class InNewProcessRunner implements JobRunner
{ {
/** @var int Default timeout for process */ /** @var int Default timeout for process */
public const DEFAULT_TIMEOUT = 3600; public const DEFAULT_TIMEOUT = 3600;
/** private LoggerInterface $logger;
* @var LoggerInterface
*/
private $logger;
/** private KernelInterface $kernel;
* @var KernelInterface
*/
private $kernel;
/** private int $timeout = self::DEFAULT_TIMEOUT;
* @var int
*/
private $timeout = self::DEFAULT_TIMEOUT;
/**
* CommandQueueHandler constructor.
*
* @param LoggerInterface $logger
* @param KernelInterface $kernel
* @param int|null $timeout
*/
public function __construct( public function __construct(
LoggerInterface $logger, LoggerInterface $logger,
KernelInterface $kernel, KernelInterface $kernel,
@ -54,9 +33,6 @@ class InNewProcessRunner implements JobRunner
} }
} }
/**
* {@inheritdoc}
*/
public function run(CommandMessage $message): void public function run(CommandMessage $message): void
{ {
$phpBinaryPath = (new PhpExecutableFinder)->find(); $phpBinaryPath = (new PhpExecutableFinder)->find();
@ -92,11 +68,6 @@ class InNewProcessRunner implements JobRunner
} }
} }
/**
* @param CommandMessage $message
*
* @return array
*/
private function getOptions(CommandMessage $message): array private function getOptions(CommandMessage $message): array
{ {
$options = []; $options = [];

View File

@ -4,15 +4,7 @@ namespace RetailCrm\ServiceBundle\Messenger\MessageHandler;
use RetailCrm\ServiceBundle\Messenger\CommandMessage; use RetailCrm\ServiceBundle\Messenger\CommandMessage;
/**
* Interface JobRunner
*
* @package RetailCrm\ServiceBundle\Messenger\MessageHandler
*/
interface JobRunner interface JobRunner
{ {
/**
* @param CommandMessage $message
*/
public function run(CommandMessage $message): void; public function run(CommandMessage $message): void;
} }

View File

@ -9,38 +9,12 @@ use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\HttpKernel\KernelInterface;
/**
* Class SimpleConsoleRunner
*
* @package RetailCrm\ServiceBundle\Messenger\MessageHandler
*/
class SimpleConsoleRunner implements JobRunner class SimpleConsoleRunner implements JobRunner
{ {
/** public function __construct(private LoggerInterface $logger, private KernelInterface $kernel)
* @var LoggerInterface
*/
private $logger;
/**
* @var KernelInterface
*/
private $kernel;
/**
* CommandQueueHandler constructor.
*
* @param LoggerInterface $logger
* @param KernelInterface $kernel
*/
public function __construct(LoggerInterface $logger, KernelInterface $kernel)
{ {
$this->logger = $logger;
$this->kernel = $kernel;
} }
/**
* {@inheritdoc}
*/
public function run(CommandMessage $message): void public function run(CommandMessage $message): void
{ {
$application = new Application($this->kernel); $application = new Application($this->kernel);

View File

@ -2,11 +2,6 @@
namespace RetailCrm\ServiceBundle\Messenger\Middleware; namespace RetailCrm\ServiceBundle\Messenger\Middleware;
/**
* Interface LockableMessage
*
* @package RetailCrm\ServiceBundle\Messenger\Middleware
*/
interface LockableMessage interface LockableMessage
{ {
public function __serialize(): array; public function __serialize(): array;

View File

@ -9,29 +9,13 @@ use Symfony\Component\Messenger\Middleware\StackInterface;
use Symfony\Component\Messenger\Stamp\ReceivedStamp; use Symfony\Component\Messenger\Stamp\ReceivedStamp;
use Throwable; use Throwable;
/**
* Class LockableMessageMiddleware
*
* @package RetailCrm\ServiceBundle\Messenger\Middleware
*/
class LockableMessageMiddleware implements MiddlewareInterface class LockableMessageMiddleware implements MiddlewareInterface
{ {
/** public function __construct(private LockFactory $lockFactory)
* @var LockFactory
*/
private $lockFactory;
public function __construct(LockFactory $lockFactory)
{ {
$this->lockFactory = $lockFactory;
} }
/** /**
* @param Envelope $envelope
* @param StackInterface $stack
*
* @return Envelope
*
* @throws Throwable * @throws Throwable
*/ */
public function handle(Envelope $envelope, StackInterface $stack): Envelope public function handle(Envelope $envelope, StackInterface $stack): Envelope
@ -56,11 +40,6 @@ class LockableMessageMiddleware implements MiddlewareInterface
return $stack->next()->handle($envelope, $stack); return $stack->next()->handle($envelope, $stack);
} }
/**
* @param LockableMessage $message
*
* @return string
*/
private function objectHash(LockableMessage $message): string private function objectHash(LockableMessage $message): string
{ {
return hash('crc32', serialize($message)); return hash('crc32', serialize($message));

View File

@ -2,25 +2,11 @@
namespace RetailCrm\ServiceBundle\Models; namespace RetailCrm\ServiceBundle\Models;
/**
* Class Error
*
* @package RetailCrm\ServiceBundle\Models
*/
class Error class Error
{ {
/** public string $code;
* @var string
*/
public $code;
/** public string $message;
* @var string
*/
public $message;
/** public array $details;
* @var array
*/
public $details;
} }

View File

@ -7,32 +7,12 @@ use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\SerializerInterface;
/**
* Class ErrorJsonResponseFactory
*
* @package RetailCrm\ServiceBundle\Response
*/
class ErrorJsonResponseFactory class ErrorJsonResponseFactory
{ {
private $serializer; public function __construct(private SerializerInterface $serializer)
/**
* ErrorJsonResponseFactory constructor.
*
* @param SerializerInterface $serializer
*/
public function __construct(SerializerInterface $serializer)
{ {
$this->serializer = $serializer;
} }
/**
* @param Error $error
* @param int $statusCode
* @param array $headers
*
* @return Response
*/
public function create(Error $error, int $statusCode = Response::HTTP_BAD_REQUEST, array $headers = []): Response public function create(Error $error, int $statusCode = Response::HTTP_BAD_REQUEST, array $headers = []): Response
{ {
return JsonResponse::fromJsonString( return JsonResponse::fromJsonString(

View File

@ -2,28 +2,9 @@
namespace RetailCrm\ServiceBundle\Serializer; namespace RetailCrm\ServiceBundle\Serializer;
/**
* Interface Adapter
*
* @package RetailCrm\ServiceBundle\Serializer
*/
interface Adapter interface Adapter
{ {
/**
* @param string $data
* @param string $type
* @param string $format
*
* @return object
*/
public function deserialize(string $data, string $type, string $format = 'json'): object; public function deserialize(string $data, string $type, string $format = 'json'): object;
/**
* @param array $data
* @param string $type
* @param string|null $format
*
* @return object
*/
public function arrayToObject(array $data, string $type, ?string $format = null): object; public function arrayToObject(array $data, string $type, ?string $format = null): object;
} }

View File

@ -6,50 +6,26 @@ use JMS\Serializer\ArrayTransformerInterface;
use JMS\Serializer\Context; use JMS\Serializer\Context;
use JMS\Serializer\SerializerInterface; use JMS\Serializer\SerializerInterface;
/**
* Class JMSSerializerAdapter
*
* @package RetailCrm\ServiceBundle\Serializer
*/
class JMSSerializerAdapter implements Adapter class JMSSerializerAdapter implements Adapter
{ {
private $serializer;
private $transformer;
private $context; private $context;
/**
* JMSSerializerAdapter constructor.
*
* @param SerializerInterface $serializer
* @param ArrayTransformerInterface $transformer
*/
public function __construct( public function __construct(
SerializerInterface $serializer, private SerializerInterface $serializer,
ArrayTransformerInterface $transformer private ArrayTransformerInterface $transformer
) { ) {
$this->serializer = $serializer;
$this->transformer = $transformer;
} }
/**
* {@inheritdoc }
*/
public function deserialize(string $data, string $type, string $format = 'json'): object public function deserialize(string $data, string $type, string $format = 'json'): object
{ {
return $this->serializer->deserialize($data, $type, $format, $this->context); return $this->serializer->deserialize($data, $type, $format, $this->context);
} }
/**
* {@inheritdoc }
*/
public function arrayToObject(array $data, string $type, ?string $format = null): object public function arrayToObject(array $data, string $type, ?string $format = null): object
{ {
return $this->transformer->fromArray($data, $type, $this->context); return $this->transformer->fromArray($data, $type, $this->context);
} }
/**
* @param Context $context
*/
public function setContext(Context $context): void public function setContext(Context $context): void
{ {
$this->context = $context; $this->context = $context;

View File

@ -5,48 +5,24 @@ namespace RetailCrm\ServiceBundle\Serializer;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\SerializerInterface;
/**
* Class SymfonySerializerAdapter
*
* @package RetailCrm\ServiceBundle\Serializer
*/
class SymfonySerializerAdapter implements Adapter class SymfonySerializerAdapter implements Adapter
{ {
private $serializer; private array $context = [];
private $denormalizer;
private $context = [];
/** public function __construct(private SerializerInterface $serializer, private DenormalizerInterface $denormalizer)
* SymfonySerializerAdapter constructor.
*
* @param SerializerInterface $serializer
* @param DenormalizerInterface $denormalizer
*/
public function __construct(SerializerInterface $serializer, DenormalizerInterface $denormalizer)
{ {
$this->serializer = $serializer;
$this->denormalizer = $denormalizer;
} }
/**
* {@inheritdoc }
*/
public function deserialize(string $data, string $type,string $format = 'json'): object public function deserialize(string $data, string $type,string $format = 'json'): object
{ {
return $this->serializer->deserialize($data, $type, $format, $this->context); return $this->serializer->deserialize($data, $type, $format, $this->context);
} }
/**
* {@inheritdoc }
*/
public function arrayToObject(array $data, string $type, string $format = null): object public function arrayToObject(array $data, string $type, string $format = null): object
{ {
return $this->denormalizer->denormalize($data, $type, $format, $this->context); return $this->denormalizer->denormalize($data, $type, $format, $this->context);
} }
/**
* @param array $context
*/
public function setContext(array $context): void public function setContext(array $context): void
{ {
$this->context = $context; $this->context = $context;

View File

@ -5,17 +5,11 @@ namespace RetailCrm\ServiceBundle\Tests\DataFixtures;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation as JMS; use JMS\Serializer\Annotation as JMS;
/**
* Class RequestDto
*
* @package RetailCrm\ServiceBundle\Tests\DataFixtures
*/
class RequestDto class RequestDto
{ {
/** /**
* @var string
* @Assert\NotNull() * @Assert\NotNull()
* @JMS\Type("string") * @JMS\Type("string")
*/ */
public $param; public string $param;
} }

View File

@ -6,11 +6,6 @@ use PHPUnit\Framework\TestCase;
use RetailCrm\ServiceBundle\DependencyInjection\Configuration; use RetailCrm\ServiceBundle\DependencyInjection\Configuration;
use Symfony\Component\Config\Definition\Processor; use Symfony\Component\Config\Definition\Processor;
/**
* Class ConfigurationTest
*
* @package RetailCrm\ServiceBundle\Tests\DependencyInjection
*/
class ConfigurationTest extends TestCase class ConfigurationTest extends TestCase
{ {
public function testConfig(): void public function testConfig(): void

View File

@ -12,11 +12,6 @@ use RetailCrm\ServiceBundle\Security\FrontApiClientAuthenticator;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag; use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag;
/**
* Class RetailCrmServiceExtensionTest
*
* @package RetailCrm\ServiceBundle\Tests\DependencyInjection
*/
class RetailCrmServiceExtensionTest extends TestCase class RetailCrmServiceExtensionTest extends TestCase
{ {
private $container; private $container;

View File

@ -3,21 +3,20 @@
namespace RetailCrm\ServiceBundle\Tests\Fixtures\App; namespace RetailCrm\ServiceBundle\Tests\Fixtures\App;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
class Kernel extends \Symfony\Component\HttpKernel\Kernel class Kernel extends \Symfony\Component\HttpKernel\Kernel
{ {
use MicroKernelTrait; use MicroKernelTrait;
public function registerBundles() public function registerBundles(): array
{ {
return [ return [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle() new \Symfony\Bundle\FrameworkBundle\FrameworkBundle()
]; ];
} }
protected function configureContainer(ContainerBuilder $container/*, LoaderInterface $loader*/): void protected function configureContainer(ContainerBuilder $container): void
{ {
$container $container
->register(TestCommand::class, TestCommand::class) ->register(TestCommand::class, TestCommand::class)
@ -26,8 +25,4 @@ class Kernel extends \Symfony\Component\HttpKernel\Kernel
$container->setParameter('kernel.project_dir', __DIR__ . '/..'); $container->setParameter('kernel.project_dir', __DIR__ . '/..');
} }
// public function registerContainerConfiguration(LoaderInterface $loader)
// {
// }
} }

View File

@ -5,11 +5,6 @@ namespace RetailCrm\ServiceBundle\Tests\Messenger;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use RetailCrm\ServiceBundle\Tests\DataFixtures\TestMessage; use RetailCrm\ServiceBundle\Tests\DataFixtures\TestMessage;
/**
* Class CommandMessageTest
*
* @package RetailCrm\ServiceBundle\Tests\Messenger
*/
class CommandMessageTest extends TestCase class CommandMessageTest extends TestCase
{ {
public function testMessage(): void public function testMessage(): void

View File

@ -7,11 +7,6 @@ use RetailCrm\ServiceBundle\Messenger\MessageHandler\InNewProcessRunner;
use RetailCrm\ServiceBundle\Tests\Fixtures\App\TestCommandMessage; use RetailCrm\ServiceBundle\Tests\Fixtures\App\TestCommandMessage;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* Class InNewProcessRunnerTest
*
* @package RetailCrm\ServiceBundle\Tests\Messenger\MessageHandler
*/
class InNewProcessRunnerTest extends KernelTestCase class InNewProcessRunnerTest extends KernelTestCase
{ {
protected function setUp(): void protected function setUp(): void

View File

@ -7,11 +7,6 @@ use RetailCrm\ServiceBundle\Messenger\MessageHandler\SimpleConsoleRunner;
use RetailCrm\ServiceBundle\Tests\Fixtures\App\TestCommandMessage; use RetailCrm\ServiceBundle\Tests\Fixtures\App\TestCommandMessage;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* Class SimpleConsoleRunnerTest
*
* @package RetailCrm\ServiceBundle\Tests\Messenger\MessageHandler
*/
class SimpleConsoleRunnerTest extends KernelTestCase class SimpleConsoleRunnerTest extends KernelTestCase
{ {
protected function setUp(): void protected function setUp(): void

View File

@ -7,11 +7,6 @@ use RetailCrm\ServiceBundle\Messenger\CommandMessage;
use RetailCrm\ServiceBundle\Messenger\MessageHandler; use RetailCrm\ServiceBundle\Messenger\MessageHandler;
use RetailCrm\ServiceBundle\Messenger\MessageHandler\JobRunner; use RetailCrm\ServiceBundle\Messenger\MessageHandler\JobRunner;
/**
* Class MessageHandlerTest
*
* @package RetailCrm\ServiceBundle\Tests\Messenger
*/
class MessageHandlerTest extends TestCase class MessageHandlerTest extends TestCase
{ {
public function testRun(): void public function testRun(): void

View File

@ -15,17 +15,9 @@ use Symfony\Component\Messenger\Middleware\MiddlewareInterface;
use Symfony\Component\Messenger\Middleware\StackInterface; use Symfony\Component\Messenger\Middleware\StackInterface;
use Symfony\Component\Messenger\Stamp\ReceivedStamp; use Symfony\Component\Messenger\Stamp\ReceivedStamp;
/**
* Class LockableMessageMiddlewareTest
*
* @package RetailCrm\ServiceBundle\Tests\Messenger\Middleware
*/
class LockableMessageMiddlewareTest extends TestCase class LockableMessageMiddlewareTest extends TestCase
{ {
/** private LockFactory $lockFactory;
* @var LockFactory
*/
private $lockFactory;
protected function setUp(): void protected function setUp(): void
{ {
@ -35,7 +27,7 @@ class LockableMessageMiddlewareTest extends TestCase
public function testHandle(): void public function testHandle(): void
{ {
$store = $this->createMock(PersistingStoreInterface::class); $store = $this->createMock(PersistingStoreInterface::class);
$key = new Key(uniqid()); $key = new Key(uniqid('', true));
$lock = new Lock($key, $store); $lock = new Lock($key, $store);
$this->lockFactory->expects(static::once())->method('createLock')->willReturn($lock); $this->lockFactory->expects(static::once())->method('createLock')->willReturn($lock);
$envelope = new Envelope(new TestMessage(), [new ReceivedStamp('test')]); $envelope = new Envelope(new TestMessage(), [new ReceivedStamp('test')]);
@ -55,7 +47,7 @@ class LockableMessageMiddlewareTest extends TestCase
{ {
$store = $this->createMock(PersistingStoreInterface::class); $store = $this->createMock(PersistingStoreInterface::class);
$store->method('save')->willThrowException(new LockConflictedException); $store->method('save')->willThrowException(new LockConflictedException);
$key = new Key(uniqid()); $key = new Key(uniqid('', true));
$lock = new Lock($key, $store); $lock = new Lock($key, $store);
$this->lockFactory->expects(static::once())->method('createLock')->willReturn($lock); $this->lockFactory->expects(static::once())->method('createLock')->willReturn($lock);
$envelope = new Envelope(new TestMessage(), [new ReceivedStamp('test')]); $envelope = new Envelope(new TestMessage(), [new ReceivedStamp('test')]);
@ -75,7 +67,7 @@ class LockableMessageMiddlewareTest extends TestCase
{ {
$store = $this->createMock(PersistingStoreInterface::class); $store = $this->createMock(PersistingStoreInterface::class);
$store->method('save')->willThrowException(new LockConflictedException); $store->method('save')->willThrowException(new LockConflictedException);
$key = new Key(uniqid()); $key = new Key(uniqid('', true));
$lock = new Lock($key, $store); $lock = new Lock($key, $store);
$this->lockFactory->expects(static::never())->method('createLock')->willReturn($lock); $this->lockFactory->expects(static::never())->method('createLock')->willReturn($lock);
$envelope = new Envelope(new \stdClass(), [new ReceivedStamp('test')]); $envelope = new Envelope(new \stdClass(), [new ReceivedStamp('test')]);
@ -95,7 +87,7 @@ class LockableMessageMiddlewareTest extends TestCase
{ {
$store = $this->createMock(PersistingStoreInterface::class); $store = $this->createMock(PersistingStoreInterface::class);
$store->method('save')->willThrowException(new LockConflictedException); $store->method('save')->willThrowException(new LockConflictedException);
$key = new Key(uniqid()); $key = new Key(uniqid('', true));
$lock = new Lock($key, $store); $lock = new Lock($key, $store);
$this->lockFactory->expects(static::never())->method('createLock')->willReturn($lock); $this->lockFactory->expects(static::never())->method('createLock')->willReturn($lock);
$envelope = new Envelope(new TestMessage()); $envelope = new Envelope(new TestMessage());

View File

@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase;
use RetailCrm\ServiceBundle\Serializer\JMSSerializerAdapter; use RetailCrm\ServiceBundle\Serializer\JMSSerializerAdapter;
use RetailCrm\ServiceBundle\Tests\DataFixtures\RequestDto; use RetailCrm\ServiceBundle\Tests\DataFixtures\RequestDto;
class JSMSerializerAdapterTest extends TestCase class JMSSerializerAdapterTest extends TestCase
{ {
private $serializer; private $serializer;
private $transformer; private $transformer;