Skip to content

Commit 5b784c3

Browse files
author
Valentin Clavreul
committed
#83 - added tests for triggered events
1 parent bc96831 commit 5b784c3

File tree

4 files changed

+71
-8
lines changed

4 files changed

+71
-8
lines changed

Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ RUN chmod +x /usr/bin/blackfire
1919
RUN docker-php-ext-enable blackfire
2020

2121
# Composer install
22-
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
23-
RUN php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
24-
RUN php composer-setup.php
25-
RUN php -r "unlink('composer-setup.php');"
26-
RUN mv /composer.phar /usr/local/bin/composer
27-
RUN chmod +x /usr/local/bin/composer
22+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
23+
24+
# PHP setup
25+
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
26+
COPY Resources/tests/environment/php/conf.ini "$PHP_INI_DIR/conf.d/"
27+
2828

2929
# Basic sample symfony app install
3030
RUN mkdir /app

Event/ConsoleProcessEvent.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
<?php
2-
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of the CleverAge/ProcessBundle package.
4+
*
5+
* Copyright (C) 2017-2019 Clever-Age
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
310

411
namespace CleverAge\ProcessBundle\Event;
512

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
memory_limit = 256M

Tests/ProcessManagerTest.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of the CleverAge/ProcessBundle package.
4+
*
5+
* Copyright (C) 2017-2019 Clever-Age
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace CleverAge\ProcessBundle\Tests;
12+
13+
use CleverAge\ProcessBundle\Context\ContextualOptionResolver;
14+
use CleverAge\ProcessBundle\Event\ProcessEvent;
15+
use CleverAge\ProcessBundle\Logger\ProcessLogger;
16+
use CleverAge\ProcessBundle\Logger\TaskLogger;
17+
use CleverAge\ProcessBundle\Manager\ProcessManager;
18+
use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry;
19+
use Prophecy\Argument\Token\TypeToken;
20+
use Prophecy\Prophecy\MethodProphecy;
21+
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
22+
23+
class ProcessManagerTest extends AbstractProcessTest
24+
{
25+
26+
public function testProcessEvents()
27+
{
28+
$edProphecy = $this->prophesize(EventDispatcherInterface::class);
29+
30+
$dispatchStartProphecy = new MethodProphecy($edProphecy, 'dispatch', [ProcessEvent::EVENT_PROCESS_STARTED, new TypeToken(ProcessEvent::class)]);
31+
$dispatchStartProphecy->shouldBeCalled();
32+
$edProphecy->addMethodProphecy($dispatchStartProphecy);
33+
34+
$dispatchStartProphecy = new MethodProphecy($edProphecy, 'dispatch', [ProcessEvent::EVENT_PROCESS_ENDED, new TypeToken(ProcessEvent::class)]);
35+
$dispatchStartProphecy->shouldBeCalled();
36+
$edProphecy->addMethodProphecy($dispatchStartProphecy);
37+
38+
$dispatchStartProphecy = new MethodProphecy($edProphecy, 'dispatch', [ProcessEvent::EVENT_PROCESS_FAILED, new TypeToken(ProcessEvent::class)]);
39+
$dispatchStartProphecy->shouldNotBeCalled();
40+
$edProphecy->addMethodProphecy($dispatchStartProphecy);
41+
42+
/** @var EventDispatcherInterface $eventDispatcher */
43+
$eventDispatcher = $edProphecy->reveal();
44+
$processManager = new ProcessManager(
45+
self::$container,
46+
self::$container->get(ProcessLogger::class),
47+
self::$container->get(TaskLogger::class),
48+
self::$container->get(ProcessConfigurationRegistry::class),
49+
self::$container->get(ContextualOptionResolver::class),
50+
$eventDispatcher
51+
);
52+
53+
$processManager->execute('test.simple_process');
54+
}
55+
}

0 commit comments

Comments
 (0)