قرینه از
https://github.com/matomo-org/matomo.git
synced 2025-08-22 06:57:53 +00:00

* prevent E_STRICT notice * fix notice in test * fix test for PHP 8.4 * ensure errors are not printed in js proxy * Fix test using mocked reflection class * set error reporting based on PHP version * Run Tests on PHP 8.4 instead of PHP 8.3 * Apply suggestions from code review Co-authored-by: Michal Kleiner <michal@innocraft.com> Co-authored-by: Liviu-Mihail Concioiu <liviu.concioiu@gmail.com> --------- Co-authored-by: Michal Kleiner <michal@innocraft.com> Co-authored-by: Liviu-Mihail Concioiu <liviu.concioiu@gmail.com>
74 خطوط
2.3 KiB
PHP
74 خطوط
2.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Matomo - free/libre analytics platform
|
|
*
|
|
* @link https://matomo.org
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
|
*/
|
|
|
|
namespace Piwik\Tests\Integration;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Piwik\API\DocumentationGenerator;
|
|
use Piwik\API\Proxy;
|
|
use Piwik\EventDispatcher;
|
|
use ReflectionClass;
|
|
|
|
/**
|
|
* @group Core
|
|
*/
|
|
class DocumentationGeneratorTest extends TestCase
|
|
{
|
|
public function testCheckIfModuleContainsHideAnnotation()
|
|
{
|
|
$reflection = new ReflectionClass(DocumentationGenerator::class);
|
|
$documentationGenerator = new DocumentationGenerator();
|
|
$this->assertTrue($documentationGenerator->checkIfClassCommentContainsHideAnnotation($reflection));
|
|
}
|
|
|
|
public function testCheckDocumentation()
|
|
{
|
|
$moduleToCheck = 'this is documentation which contains @hideExceptForSuperUser';
|
|
$documentationAfterCheck = 'this is documentation which contains ';
|
|
$documentationGenerator = new DocumentationGenerator();
|
|
$this->assertEquals($documentationGenerator->checkDocumentation($moduleToCheck), $documentationAfterCheck);
|
|
}
|
|
|
|
public function testCheckIfMethodCommentContainsHideAnnotationAndText()
|
|
{
|
|
$annotation = '@hideForAll test test';
|
|
EventDispatcher::getInstance()->addObserver(
|
|
'API.DocumentationGenerator.@hideForAll',
|
|
function (&$hide) {
|
|
$hide = true;
|
|
}
|
|
);
|
|
$this->assertEquals(Proxy::getInstance()->shouldHideAPIMethod($annotation), true);
|
|
}
|
|
|
|
public function testCheckIfMethodCommentContainsHideAnnotationOnly()
|
|
{
|
|
$annotation = '@hideForAll';
|
|
EventDispatcher::getInstance()->addObserver(
|
|
'API.DocumentationGenerator.@hideForAll',
|
|
function (&$hide) {
|
|
$hide = true;
|
|
}
|
|
);
|
|
$this->assertEquals(Proxy::getInstance()->shouldHideAPIMethod($annotation), true);
|
|
}
|
|
|
|
public function testCheckIfMethodCommentDoesNotContainHideAnnotation()
|
|
{
|
|
$annotation = '@not found here';
|
|
EventDispatcher::getInstance()->addObserver(
|
|
'API.DocumentationGenerator.@hello',
|
|
function (&$hide) {
|
|
$hide = true;
|
|
}
|
|
);
|
|
$this->assertEquals(Proxy::getInstance()->shouldHideAPIMethod($annotation), false);
|
|
}
|
|
}
|