1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
declare(strict_types=1);
namespace Piwik\Plugins\CoreAdminHome\tests\Fixtures;
use Closure;
use Piwik\Container\Container;
use Piwik\DI;
use Piwik\Plugins\CoreAdminHome\tests\Fixtures\RunScheduledTasksProcessSignal\StepControl;
use Piwik\Plugins\Monolog\Handler\EchoHandler;
use Piwik\Tests\Framework\Fixture;
/**
* Provides container configuration and helpers to run process signal tests.
*/
class RunScheduledTasksProcessSignal extends Fixture
{
public const ENV_TRIGGER = 'MATOMO_TEST_RUN_SCHEDULED_TASKS_PROCESS_SIGNAL';
/**
* @var int
*/
public $idSite = 1;
/**
* @var StepControl
*/
public $stepControl;
/**
* @var bool
*/
private $inTestEnv;
public function __construct()
{
$this->inTestEnv = (bool) getenv(self::ENV_TRIGGER);
$this->stepControl = new StepControl();
}
public function setUp(): void
{
Fixture::createSuperUser();
if (!self::siteCreated($this->idSite)) {
self::createWebsite('2021-01-01');
}
}
public function tearDown(): void
{
// empty
}
public function provideContainerConfig(): array
{
if (!$this->inTestEnv) {
return [];
}
return [
'ini.tests.enable_logging' => 1,
'log.handlers' => static function (Container $c) {
return [$c->get(EchoHandler::class)];
},
'observers.global' => DI::add([
[
'ScheduledTasks.execute',
DI::value(Closure::fromCallable([$this->stepControl, 'handleScheduledTasksExecute'])),
],
]),
];
}
}
|