diff options
author | Stefan Giehl <stefan@matomo.org> | 2020-09-03 04:51:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-03 04:51:18 +0300 |
commit | 3565da78bff718f201247fc2f692c0be29220fde (patch) | |
tree | e8268373b284c293c307935a8bfa20d5cd920b48 /tests | |
parent | 21cafb0533d07acbe0a574e23bd972b20d72aa90 (diff) |
Updates php-di to 6.2.1 (#16311)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PHPUnit/Fixtures/UITestFixture.php | 12 | ||||
-rw-r--r-- | tests/PHPUnit/Framework/TestingEnvironmentManipulator.php | 2 | ||||
-rw-r--r-- | tests/PHPUnit/Framework/TestingEnvironmentVariables.php | 5 | ||||
-rw-r--r-- | tests/PHPUnit/Framework/TestingEnvironmentVariablesDefinitionSource.php | 20 | ||||
-rw-r--r-- | tests/PHPUnit/Framework/XssTesting.php | 4 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/ArchiveWebTest.php | 8 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/AssetManagerTest.php | 2 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/CronArchiveTest.php | 2 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/Period/FactoryTest.php | 2 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/SegmentTest.php | 6 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/Session/SessionAuthTest.php | 2 | ||||
-rw-r--r-- | tests/PHPUnit/System/ConsoleTest.php | 13 | ||||
-rw-r--r-- | tests/PHPUnit/System/ImportLogsTest.php | 8 | ||||
-rw-r--r-- | tests/PHPUnit/proxy/piwik.php | 4 |
14 files changed, 57 insertions, 33 deletions
diff --git a/tests/PHPUnit/Fixtures/UITestFixture.php b/tests/PHPUnit/Fixtures/UITestFixture.php index b75ebe079b..297fcaaa5a 100644 --- a/tests/PHPUnit/Fixtures/UITestFixture.php +++ b/tests/PHPUnit/Fixtures/UITestFixture.php @@ -467,7 +467,7 @@ class UITestFixture extends SqlDump return [ 'Tests.now' => \DI\decorate(function(){ return Option::get("Tests.forcedNowTimestamp"); }), 'observers.global' => \DI\add([ - ['Report.addReports', function (&$reports) { + ['Report.addReports', \DI\value(function (&$reports) { $report = new XssReport(); $report->initForXss('forTwig'); $reports[] = $report; @@ -475,11 +475,11 @@ class UITestFixture extends SqlDump $report = new XssReport(); $report->initForXss('forAngular'); $reports[] = $report; - }], - ['Dimension.addDimensions', function (&$instances) { + })], + ['Dimension.addDimensions', \DI\value(function (&$instances) { $instances[] = new XssDimension(); - }], - ['API.Request.intercept', function (&$result, $finalParameters, $pluginName, $methodName) { + })], + ['API.Request.intercept', \DI\value(function (&$result, $finalParameters, $pluginName, $methodName) { if ($pluginName != 'ExampleAPI' && $methodName != 'xssReportforTwig' && $methodName != 'xssReportforAngular') { return; } @@ -498,7 +498,7 @@ class UITestFixture extends SqlDump 'nb_visits' => 15, ]); $result = $dataTable; - }], + })], ]), Proxy::class => \DI\get(CustomApiProxy::class), 'log.handlers' => \DI\decorate(function ($previous, ContainerInterface $c) { diff --git a/tests/PHPUnit/Framework/TestingEnvironmentManipulator.php b/tests/PHPUnit/Framework/TestingEnvironmentManipulator.php index f41c51f266..8a836b0e39 100644 --- a/tests/PHPUnit/Framework/TestingEnvironmentManipulator.php +++ b/tests/PHPUnit/Framework/TestingEnvironmentManipulator.php @@ -8,7 +8,7 @@ namespace Piwik\Tests\Framework; -use Interop\Container\ContainerInterface; +use Psr\Container\ContainerInterface; use Piwik\Application\Environment; use Piwik\Application\EnvironmentManipulator; use Piwik\Application\Kernel\GlobalSettingsProvider; diff --git a/tests/PHPUnit/Framework/TestingEnvironmentVariables.php b/tests/PHPUnit/Framework/TestingEnvironmentVariables.php index 992368b55a..697caf7a95 100644 --- a/tests/PHPUnit/Framework/TestingEnvironmentVariables.php +++ b/tests/PHPUnit/Framework/TestingEnvironmentVariables.php @@ -40,6 +40,11 @@ class TestingEnvironmentVariables return isset($this->behaviorOverrideProperties[$name]); } + public function getProperties() + { + return $this->behaviorOverrideProperties; + } + /** * Overrides a config entry. * diff --git a/tests/PHPUnit/Framework/TestingEnvironmentVariablesDefinitionSource.php b/tests/PHPUnit/Framework/TestingEnvironmentVariablesDefinitionSource.php index 525c2a7a35..837cb2e883 100644 --- a/tests/PHPUnit/Framework/TestingEnvironmentVariablesDefinitionSource.php +++ b/tests/PHPUnit/Framework/TestingEnvironmentVariablesDefinitionSource.php @@ -22,7 +22,6 @@ class TestingEnvironmentVariablesDefinitionSource implements DefinitionSource private $prefix; /** - * @param TestingEnvironmentVariables $vars * @param string $prefix */ public function __construct($prefix = 'test.vars.') @@ -42,7 +41,24 @@ class TestingEnvironmentVariablesDefinitionSource implements DefinitionSource $variableName = $this->parseVariableName($name); $vars = new TestingEnvironmentVariables(); - return new ValueDefinition($name, $vars->$variableName); + $value = new ValueDefinition($vars->$variableName); + $value->setName($name); + return $value; + } + + public function getDefinitions(): array + { + $vars = new TestingEnvironmentVariables(); + $properties = $vars->getProperties(); + + $result = []; + foreach ($properties as $name => $property) { + $value = new ValueDefinition($property); + $value->setName($name); + $result[] = $value; + } + + return $result; } private function parseVariableName($name) diff --git a/tests/PHPUnit/Framework/XssTesting.php b/tests/PHPUnit/Framework/XssTesting.php index 0c5a8d03d2..b037a72aa4 100644 --- a/tests/PHPUnit/Framework/XssTesting.php +++ b/tests/PHPUnit/Framework/XssTesting.php @@ -91,9 +91,9 @@ JS; public static function getJavaScriptAddEvent() { $xssTesting = new XssTesting(); - return ['Template.jsGlobalVariables', function (&$out) use ($xssTesting) { + return ['Template.jsGlobalVariables', \DI\value(function (&$out) use ($xssTesting) { $out .= $xssTesting->getJavaScriptCode(); - }]; + })]; } /** diff --git a/tests/PHPUnit/Integration/ArchiveWebTest.php b/tests/PHPUnit/Integration/ArchiveWebTest.php index 1b9841ccc3..802c3194a1 100644 --- a/tests/PHPUnit/Integration/ArchiveWebTest.php +++ b/tests/PHPUnit/Integration/ArchiveWebTest.php @@ -70,17 +70,17 @@ class ArchiveWebTest extends SystemTestCase 'Psr\Log\LoggerInterface' => \DI\get('Monolog\Logger'), 'Tests.log.allowAllHandlers' => true, 'observers.global' => [ - ['API.Request.intercept', function (&$returnedValue, $finalParameters, $pluginName, $methodName, $parametersRequest) { + ['API.Request.intercept', \DI\value(function (&$returnedValue, $finalParameters, $pluginName, $methodName, $parametersRequest) { if ($pluginName == 'CoreAdminHome' && $methodName == 'runCronArchiving') { $returnedValue = 'mock output'; } - }], - ['Console.doRun', function (&$exitCode, InputInterface $input, OutputInterface $output) { + })], + ['Console.doRun', \DI\value(function (&$exitCode, InputInterface $input, OutputInterface $output) { if ($input->getFirstArgument() == 'core:archive') { $output->writeln('mock output'); $exitCode = 0; } - }], + })], ], ); } diff --git a/tests/PHPUnit/Integration/AssetManagerTest.php b/tests/PHPUnit/Integration/AssetManagerTest.php index 249b00c8d7..360d4352aa 100644 --- a/tests/PHPUnit/Integration/AssetManagerTest.php +++ b/tests/PHPUnit/Integration/AssetManagerTest.php @@ -92,7 +92,7 @@ class AssetManagerTest extends IntegrationTestCase public function provideContainerConfig() { return array( - 'Piwik\Plugin\Manager' => \DI\object('Piwik\Tests\Unit\AssetManager\PluginManagerMock') + 'Piwik\Plugin\Manager' => \DI\autowire('Piwik\Tests\Unit\AssetManager\PluginManagerMock') ); } diff --git a/tests/PHPUnit/Integration/CronArchiveTest.php b/tests/PHPUnit/Integration/CronArchiveTest.php index 0fc0992f4f..6a1613c22e 100644 --- a/tests/PHPUnit/Integration/CronArchiveTest.php +++ b/tests/PHPUnit/Integration/CronArchiveTest.php @@ -455,7 +455,7 @@ LOG; Date::$now = strtotime('2020-02-03 04:05:06'); return array( - 'Piwik\CliMulti' => \DI\object('Piwik\Tests\Framework\Mock\FakeCliMulti') + 'Piwik\CliMulti' => \DI\create('Piwik\Tests\Framework\Mock\FakeCliMulti') ); } diff --git a/tests/PHPUnit/Integration/Period/FactoryTest.php b/tests/PHPUnit/Integration/Period/FactoryTest.php index 2934715e68..9ff978a646 100644 --- a/tests/PHPUnit/Integration/Period/FactoryTest.php +++ b/tests/PHPUnit/Integration/Period/FactoryTest.php @@ -128,7 +128,7 @@ class FactoryTest extends IntegrationTestCase public function provideContainerConfig() { return [ - \Piwik\Plugin\Manager::class => \DI\object(MockPluginManager::class), + \Piwik\Plugin\Manager::class => \DI\autowire(MockPluginManager::class), ]; } } diff --git a/tests/PHPUnit/Integration/SegmentTest.php b/tests/PHPUnit/Integration/SegmentTest.php index ecca62eaf3..557c44d023 100644 --- a/tests/PHPUnit/Integration/SegmentTest.php +++ b/tests/PHPUnit/Integration/SegmentTest.php @@ -1868,7 +1868,7 @@ log_visit.visit_total_actions return array( 'Piwik\Access' => new FakeAccess(), - 'Piwik\Tracker\TableLogAction\Cache' => \DI\object()->constructorParameter('cache', $cacheProxy), + 'Piwik\Tracker\TableLogAction\Cache' => \DI\autowire()->constructorParameter('cache', $cacheProxy), ); } @@ -2021,14 +2021,14 @@ log_visit.visit_total_actions { return [ 'observers.global' => [ - ['Segment.addSegments', function (Segment\SegmentsList $list) { + ['Segment.addSegments', \DI\value(function (Segment\SegmentsList $list) { $segment = new \Piwik\Plugin\Segment(); $segment->setSegment('customSegment'); $segment->setType(\Piwik\Plugin\Segment::TYPE_DIMENSION); $segment->setName('Custom Segment'); $segment->setSqlSegment('(UNIX_TIMESTAMP(log_visit.visit_first_action_time) - log_visit.visitor_seconds_since_first)'); $list->addSegment($segment); - }], + })], ], ]; } diff --git a/tests/PHPUnit/Integration/Session/SessionAuthTest.php b/tests/PHPUnit/Integration/Session/SessionAuthTest.php index 2b322c812c..3f0c2142d1 100644 --- a/tests/PHPUnit/Integration/Session/SessionAuthTest.php +++ b/tests/PHPUnit/Integration/Session/SessionAuthTest.php @@ -154,7 +154,7 @@ class SessionAuthTest extends IntegrationTestCase public function provideContainerConfig() { return [ - SessionAuth::class => \DI\object() + SessionAuth::class => \DI\autowire() ->constructorParameter('shouldDestroySession', false), ]; } diff --git a/tests/PHPUnit/System/ConsoleTest.php b/tests/PHPUnit/System/ConsoleTest.php index 25b7f164a2..1fd9d8330d 100644 --- a/tests/PHPUnit/System/ConsoleTest.php +++ b/tests/PHPUnit/System/ConsoleTest.php @@ -105,6 +105,9 @@ class TestCommandWithException extends ConsoleCommand } } +/** + * @group ConsoleTest3 + */ class ConsoleTest extends ConsoleCommandTestCase { public function setUp(): void @@ -215,20 +218,20 @@ END; { return [ 'log.handlers' => [\DI\get(FailureLogMessageDetector::class)], - LoggerInterface::class => \DI\object(Logger::class) + LoggerInterface::class => \DI\create(Logger::class) ->constructor('piwik', \DI\get('log.handlers'), \DI\get('log.processors')), 'observers.global' => \DI\add([ - ['Console.filterCommands', function (&$commands) { + ['Console.filterCommands', \DI\value(function (&$commands) { $commands[] = TestCommandWithFatalError::class; $commands[] = TestCommandWithException::class; - }], + })], - ['Request.dispatch', function ($module, $action) { + ['Request.dispatch', \DI\value(function ($module, $action) { if ($module === 'CorePluginsAdmin' && $action === 'safemode') { print "*** IN SAFEMODE ***\n"; // will appear in output } - }], + })], ]), ]; } diff --git a/tests/PHPUnit/System/ImportLogsTest.php b/tests/PHPUnit/System/ImportLogsTest.php index 6129d07fe0..757e3b1817 100644 --- a/tests/PHPUnit/System/ImportLogsTest.php +++ b/tests/PHPUnit/System/ImportLogsTest.php @@ -195,17 +195,17 @@ class ImportLogsTest extends SystemTestCase $testingEnvironment = new TestingEnvironmentVariables(); if ($testingEnvironment->_triggerTrackerFailure) { - $observers[] = array('Tracker.newHandler', function () { + $observers[] = array('Tracker.newHandler', \DI\value(function () { @http_response_code(500); throw new \Exception("injected exception"); - }); + })); } if ($testingEnvironment->_triggerInvalidRequests) { // we trigger an invalid request by checking for triggerInvalid=1 in a request, and if found replacing the // request w/ a request that has an nonexistent idsite - $observers[] = array('Tracker.initRequestSet', function (RequestSet $requestSet) { + $observers[] = array('Tracker.initRequestSet', \DI\value(function (RequestSet $requestSet) { $requests = $requestSet->getRequests(); foreach ($requests as $index => $request) { $url = $request->getParam('url'); @@ -217,7 +217,7 @@ class ImportLogsTest extends SystemTestCase } } $requestSet->setRequests($requests); - }); + })); } if (!empty($observers)) { diff --git a/tests/PHPUnit/proxy/piwik.php b/tests/PHPUnit/proxy/piwik.php index 8135659410..216a1143c1 100644 --- a/tests/PHPUnit/proxy/piwik.php +++ b/tests/PHPUnit/proxy/piwik.php @@ -23,12 +23,12 @@ ob_start(); try { $globalObservers = array( - array('Environment.bootstrapped', function () { + array('Environment.bootstrapped', \DI\value(function () { Tracker::setTestEnvironment(); Manager::getInstance()->deleteAll(); Option::clearCache(); Site::clearCache(); - }) + })) ); Environment::setGlobalEnvironmentManipulator(new TestingEnvironmentManipulator(new TestingEnvironmentVariables(), $globalObservers)); |