Skip to content

Commit

Permalink
Merge pull request #235 from matomo-org/PG-3334-check-direct-dep
Browse files Browse the repository at this point in the history
Added tests to check direct use of core dependencies, #PG-3334
  • Loading branch information
AltamashShaikh authored Mar 12, 2024
2 parents f141c15 + 4b5bfd0 commit 42846df
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/matomo-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
47 changes: 47 additions & 0 deletions tests/System/CheckDirectDependencyUseCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/

namespace Piwik\Plugins\QueuedTracking\tests\System;

use Piwik\Plugins\TestRunner\Commands\CheckDirectDependencyUse;
use Piwik\Tests\Framework\TestCase\SystemTestCase;
use Piwik\Version;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;

class CheckDirectDependencyUseCommandTest extends SystemTestCase
{
public function testCommand()
{
if (version_compare(Version::VERSION, '5.0.3', '<=') && !file_exists(PIWIK_INCLUDE_PATH . '/plugins/TestRunner/Commands/CheckDirectDependencyUse.php')) {
$this->markTestSkipped('tests:check-direct-dependency-use is not available in this version');
}

$pluginName = 'QueuedTracking';

$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' => [
'QueuedTracking/tests/System/CheckDirectDependencyUseCommandTest.php'
],
], $checkDirectDependencyUse->usesFoundList[$pluginName]);
}
}

0 comments on commit 42846df

Please sign in to comment.