Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests to check direct use of core dependencies, #PG-3334 #72

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion .github/workflows/matomo-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,30 @@ concurrency:
cancel-in-progress: true

jobs:
PluginTests:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
php: [ '7.2', '8.2' ]
target: ['minimum_required_matomo', 'maximum_supported_matomo']
steps:
- uses: actions/checkout@v3
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:
plugin-name: 'InvalidateReports'
php-version: ${{ matrix.php }}
test-type: 'PluginTests'
matomo-test-branch: ${{ matrix.target }}
artifacts-pass: ${{ secrets.ARTIFACTS_PASS }}
upload-artifacts: ${{ matrix.php == '7.2' && matrix.target == 'maximum_supported_matomo' }}
artifacts-protected: true
UI:
runs-on: ubuntu-20.04
steps:
Expand All @@ -42,7 +66,6 @@ jobs:
- name: running tests
uses: matomo-org/github-action-tests@main
with:
testomatio: ${{ secrets.TESTOMATIO }}
plugin-name: 'InvalidateReports'
matomo-test-branch: 'maximum_supported_matomo'
test-type: 'UI'
Expand Down
53 changes: 53 additions & 0 deletions tests/System/CheckDirectDependencyUseCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* Copyright (C) InnoCraft Ltd - All rights reserved.
*
* NOTICE: All information contained herein is, and remains the property of InnoCraft Ltd.
* The intellectual and technical concepts contained herein are protected by trade secret or copyright law.
* Redistribution of this information or reproduction of this material is strictly forbidden
* unless prior written permission is obtained from InnoCraft Ltd.
*
* You shall use this code only in accordance with the license agreement obtained from InnoCraft Ltd.
*
* @link https://www.innocraft.com/
* @license For license details see https://www.innocraft.com/license
*/

namespace Piwik\Plugins\InvalidateReports\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 = 'InvalidateReports';
$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' => [
'InvalidateReports/tests/System/CheckDirectDependencyUseCommandTest.php'
],
], $checkDirectDependencyUse->usesFoundList[$pluginName]);
}
}
Loading