Skip to content

Commit

Permalink
Switch to phpunit (part 2)
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher authored Jul 4, 2024
1 parent 14148d5 commit ebf789a
Show file tree
Hide file tree
Showing 66 changed files with 4,511 additions and 4,240 deletions.
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
<directory suffix=".php">phpunit/functional/</directory>
</testsuite>
</testsuites>
<php>
<ini name="memory_limit" value="256M" />
</php>
</phpunit>

2 changes: 1 addition & 1 deletion phpunit/DbTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ protected function getClasses($function = false, array $excludes = [])
$excludes = array_merge(
$excludes,
[
'TicketFollowup', // Deprecated
'/^TicketFollowup$/', // Deprecated
'/^RuleImportComputer.*/', // Deprecated
]
);
Expand Down
5 changes: 5 additions & 0 deletions phpunit/GLPITestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

use Glpi\Tests\Log\TestHandler;
use Monolog\Logger;
use org\bovigo\vfs\vfsStreamWrapper;
use PHPUnit\Framework\TestCase;
use Psr\Log\LogLevel;

Expand Down Expand Up @@ -72,10 +73,14 @@ public function setUp(): void
$PHPLOGGER->setHandlers([$this->php_log_handler]);
$this->sql_log_handler = new TestHandler(LogLevel::DEBUG);
$SQLLOGGER->setHandlers([$this->sql_log_handler]);

vfsStreamWrapper::register();
}

public function tearDown(): void
{
vfsStreamWrapper::unregister();

if (isset($_SESSION['MESSAGE_AFTER_REDIRECT']) && !$this->has_failed) {
unset($_SESSION['MESSAGE_AFTER_REDIRECT'][INFO]);
$this->assertSame(
Expand Down
2 changes: 1 addition & 1 deletion phpunit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
include_once __DIR__ . '/InventoryTestCase.php';
//include_once __DIR__ . '/functional/CommonITILRecurrent.php';
//include_once __DIR__ . '/functional/Glpi/ContentTemplates/Parameters/AbstractParameters.php';
//include_once __DIR__ . '/functional/AbstractRightsDropdown.php';
include_once __DIR__ . '/functional/AbstractRightsDropdown.php';

// check folder exists instead of class_exists('\GuzzleHttp\Client'), to prevent global includes
if (file_exists(__DIR__ . '/../vendor/autoload.php') && !file_exists(__DIR__ . '/../vendor/guzzlehttp/guzzle')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

abstract class AbstractRightsDropdown extends \GLPITestCase
{
protected function testGetPostedIdsProvider(): Generator
public static function getPostedIdsProvider(): Generator
{
$flat_values_set = [
'users_id-3',
Expand Down Expand Up @@ -91,14 +91,14 @@ protected function testGetPostedIdsProvider(): Generator
}

/**
* @dataprovider testGetPostedIdsProvider
* @dataProvider getPostedIdsProvider
*/
public function testGetPostedIds(
array $values,
string $class,
array $expected_ids
): void {
$ids = \AbstractRightsDropdown::getPostedIds($values, $class);
$this->array($ids)->isEqualTo($expected_ids);
$this->assertSame($expected_ids, $ids);
}
}
Loading

0 comments on commit ebf789a

Please sign in to comment.