1
0
Fork 0
mirror of synced 2025-04-05 06:03:34 +03:00

add tests and phpdoc

This commit is contained in:
Akolzin Dmitry 2021-03-30 15:20:02 +03:00
parent e7d19dcad1
commit 1b66e4ee3a
5 changed files with 89 additions and 0 deletions

View file

@ -0,0 +1,15 @@
<?php
namespace RetailCrm\ServiceBundle\Tests\DataFixtures;
use RetailCrm\ServiceBundle\Messenger\CommandMessage;
class TestMessage extends CommandMessage
{
public function __construct()
{
$this->commandName = 'test';
$this->arguments = ['argument' => 'argument'];
$this->options = ['option' => 'option'];
}
}

View file

@ -0,0 +1,38 @@
<?php
namespace RetailCrm\ServiceBundle\Tests\Messenger;
use PHPUnit\Framework\TestCase;
use RetailCrm\ServiceBundle\Tests\DataFixtures\TestMessage;
/**
* Class CommandMessageTest
*
* @package RetailCrm\ServiceBundle\Tests\Messenger
*/
class CommandMessageTest extends TestCase
{
public function testMessage(): void
{
$message = new TestMessage();
static::assertEquals('test', $message->getCommandName());
static::assertEquals(['argument' => 'argument'], $message->getArguments());
static::assertEquals(['option' => 'option'], $message->getOptions());
static::assertEquals(['--option' => 'option'], $message->getFormattedOptions());
$message->addOption('option2', 'option2');
$message->addArgument('argument2', 'argument2');
static::assertEquals(['argument' => 'argument', 'argument2' => 'argument2'], $message->getArguments());
static::assertEquals(['option' => 'option', 'option2' => 'option2'], $message->getOptions());
static::assertEquals(['--option' => 'option', '--option2' => 'option2'], $message->getFormattedOptions());
$message->setOptions(['option' => 'option']);
$message->setArguments(['argument' => 'argument']);
static::assertEquals(['argument' => 'argument'], $message->getArguments());
static::assertEquals(['option' => 'option'], $message->getOptions());
static::assertEquals(['--option' => 'option'], $message->getFormattedOptions());
}
}

View file

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

View file

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

View file

@ -0,0 +1,26 @@
<?php
namespace RetailCrm\ServiceBundle\Tests\Messenger;
use PHPUnit\Framework\TestCase;
use RetailCrm\ServiceBundle\Messenger\CommandMessage;
use RetailCrm\ServiceBundle\Messenger\MessageHandler;
use RetailCrm\ServiceBundle\Messenger\MessageHandler\JobRunner;
/**
* Class MessageHandlerTest
*
* @package RetailCrm\ServiceBundle\Tests\Messenger
*/
class MessageHandlerTest extends TestCase
{
public function testRun(): void
{
$runner = $this->createMock(JobRunner::class);
$runner->expects(static::once())->method('run');
$message = $this->createMock(CommandMessage::class);
$handler = new MessageHandler($runner);
$handler->__invoke($message);
}
}