From f4bb1760c9d6cbc7673160f7ce79b9b5c34c23fa Mon Sep 17 00:00:00 2001 From: Altamash Shaikh Date: Tue, 12 Mar 2024 02:31:32 +0530 Subject: [PATCH] Added tests to check direct use of core dependencies, #PG-3334 --- .github/workflows/matomo-tests.yml | 2 + .../CheckDirectDependencyUseCommandTest.php | 50 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 tests/System/CheckDirectDependencyUseCommandTest.php diff --git a/.github/workflows/matomo-tests.yml b/.github/workflows/matomo-tests.yml index eba3fc4..483b0f0 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..e3db577 --- /dev/null +++ b/tests/System/CheckDirectDependencyUseCommandTest.php @@ -0,0 +1,50 @@ +markTestSkipped('tests:check-direct-dependency-use is not available in this version'); + } + + $pluginName = 'CustomAlerts'; + + $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' => [ + 'CustomAlerts/tests/System/CheckDirectDependencyUseCommandTest.php' + ], + 'PHPMailer\PHPMailer' => [ + 'CustomAlerts/tests/Integration/NotifierTest.php' + ], + ], $checkDirectDependencyUse->usesFoundList[$pluginName]); + } +} \ No newline at end of file