From 3fbec04c2243f32449aa5be070b9d00a431e69b5 Mon Sep 17 00:00:00 2001 From: Altamash Shaikh Date: Tue, 12 Mar 2024 02:38:22 +0530 Subject: [PATCH] Added tests to check direct use of core dependencies, #PG-3334 --- .github/workflows/matomo-tests.yml | 2 + .../CheckDirectDependencyUseCommandTest.php | 49 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 tests/System/CheckDirectDependencyUseCommandTest.php diff --git a/.github/workflows/matomo-tests.yml b/.github/workflows/matomo-tests.yml index d83f4c5..140dd27 100644 --- a/.github/workflows/matomo-tests.yml +++ b/.github/workflows/matomo-tests.yml @@ -44,6 +44,8 @@ jobs: with: lfs: true persist-credentials: false + - name: Install package ripgrep + run: sudo apt-get install ripgrep - name: Run tests uses: matomo-org/github-action-tests@main with: diff --git a/tests/System/CheckDirectDependencyUseCommandTest.php b/tests/System/CheckDirectDependencyUseCommandTest.php new file mode 100644 index 0000000..48adda2 --- /dev/null +++ b/tests/System/CheckDirectDependencyUseCommandTest.php @@ -0,0 +1,49 @@ +markTestSkipped('tests:check-direct-dependency-use is not available in this version'); + } + + $pluginName = 'CustomVariables'; + + $checkDirectDependencyUse = new CheckDirectDependencyUse(); + + $console = new \Piwik\Console(self::$fixture->piwikEnvironment); + $console->addCommands([$checkDirectDependencyUse]); + $command = $console->find('tests:check-direct-dependency-use'); + $arguments = [ + 'command' => 'tests:check-direct-dependency-use', + '--plugin' => $pluginName, + '--grep-vendor', + ]; + + $inputObject = new ArrayInput($arguments); + $command->run($inputObject, new NullOutput()); + + $this->assertEquals([ + 'Symfony\Component\Console' => [ + 'CustomVariables/tests/Commands/InfoTest.php', + 'CustomVariables/tests/Commands/SetNumberOfCustomVariablesTest.php', + 'CustomVariables/tests/System/CheckDirectDependencyUseCommandTest.php' + ], + ], $checkDirectDependencyUse->usesFoundList[$pluginName]); + } +} \ No newline at end of file