Skip to content

Commit 3e9be53

Browse files
Merge pull request #171 from matomo-org/PG-3334-check-direct-dep
Added tests to check direct use of core dependencies, #PG-3334
2 parents 257933a + f4bb176 commit 3e9be53

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

.github/workflows/matomo-tests.yml

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ jobs:
4444
with:
4545
lfs: true
4646
persist-credentials: false
47+
- name: Install package ripgrep
48+
run: sudo apt-get install ripgrep
4749
- name: Run tests
4850
uses: matomo-org/github-action-tests@main
4951
with:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* Piwik - free/libre analytics platform
4+
*
5+
* @link http://piwik.org
6+
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
7+
*/
8+
9+
namespace Piwik\Plugins\CustomAlerts\tests\System;
10+
11+
use Piwik\Plugins\TestRunner\Commands\CheckDirectDependencyUse;
12+
use Piwik\Tests\Framework\TestCase\SystemTestCase;
13+
use Piwik\Version;
14+
use Symfony\Component\Console\Input\ArrayInput;
15+
use Symfony\Component\Console\Output\NullOutput;
16+
17+
class CheckDirectDependencyUseCommandTest extends SystemTestCase
18+
{
19+
public function testCommand()
20+
{
21+
if (version_compare(Version::VERSION, '5.0.3', '<=') && !file_exists(PIWIK_INCLUDE_PATH . '/plugins/TestRunner/Commands/CheckDirectDependencyUse.php')) {
22+
$this->markTestSkipped('tests:check-direct-dependency-use is not available in this version');
23+
}
24+
25+
$pluginName = 'CustomAlerts';
26+
27+
$checkDirectDependencyUse = new CheckDirectDependencyUse();
28+
29+
$console = new \Piwik\Console(self::$fixture->piwikEnvironment);
30+
$console->addCommands([$checkDirectDependencyUse]);
31+
$command = $console->find('tests:check-direct-dependency-use');
32+
$arguments = [
33+
'command' => 'tests:check-direct-dependency-use',
34+
'--plugin' => $pluginName,
35+
'--grep-vendor',
36+
];
37+
38+
$inputObject = new ArrayInput($arguments);
39+
$command->run($inputObject, new NullOutput());
40+
41+
$this->assertEquals([
42+
'Symfony\Component\Console' => [
43+
'CustomAlerts/tests/System/CheckDirectDependencyUseCommandTest.php'
44+
],
45+
'PHPMailer\PHPMailer' => [
46+
'CustomAlerts/tests/Integration/NotifierTest.php'
47+
],
48+
], $checkDirectDependencyUse->usesFoundList[$pluginName]);
49+
}
50+
}

0 commit comments

Comments
 (0)