Skip to content

Commit

Permalink
Migrate PHPUnit to 8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Skouat committed Sep 27, 2024
1 parent b573b24 commit 677d306
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 32 deletions.
11 changes: 6 additions & 5 deletions tests/epv_test_validate_php_functions_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Phpbb\Epv\Files\FileLoader;
use Phpbb\Epv\Tests\Mock\Output;
use Phpbb\Epv\Tests\Tests\epv_test_validate_php_functions;
use PHPUnit\Framework\TestCase;

/**
*
Expand All @@ -14,9 +15,9 @@
*
*/

class epv_test_validate_php_functions_test extends PHPUnit_Framework_TestCase
class epv_test_validate_php_functions_test extends TestCase
{
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
require_once('./tests/Mock/Output.php');
}
Expand Down Expand Up @@ -74,7 +75,7 @@ public function test_usage_of_addslashes() {

public function test_usage_of_evals() {
$output = $this->getOutputMock();
$output->expects(self::exactly(1))
$output->expects(self::once())
->method('addMessage')
->with(OutputInterface::FATAL, 'The use of eval() is not allowed for security reasons on line 8 in tests/testFiles/eval.php')
;
Expand All @@ -87,7 +88,7 @@ public function test_usage_of_evals() {

public function test_usage_of_no_inphpbb() {
$output = $this->getOutputMock();
$output->expects(self::exactly(1))
$output->expects(self::once())
->method('addMessage')
->with(OutputInterface::WARNING, 'IN_PHPBB is not defined in tests/testFiles/no_in_phpbb.php')
;
Expand Down Expand Up @@ -176,7 +177,7 @@ private function getLoader()
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|OutputInterface
* @return PHPUnit\Framework\MockObject\MockObject|OutputInterface
*/
function getOutputMock()
{
Expand Down
5 changes: 3 additions & 2 deletions tests/file_loader_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
use Phpbb\Epv\Files\Type\PHPFileInterface;
use Phpbb\Epv\Files\Type\YmlFile;
use Phpbb\Epv\Tests\Mock\Output;
use PHPUnit\Framework\TestCase;

class file_loader_test extends PHPUnit_Framework_TestCase {
class file_loader_test extends TestCase {

/** @var FileLoader */
private static $loader;

public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
require_once('./tests/Mock/Output.php');

Expand Down
5 changes: 3 additions & 2 deletions tests/php_exporter_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
use Phpbb\Epv\Events\php_exporter;
use Phpbb\Epv\Output\OutputInterface;
use Phpbb\Epv\Tests\Mock\Output;
use PHPUnit\Framework\TestCase;

class php_exporter_test extends \PHPUnit_Framework_TestCase
class php_exporter_test extends TestCase
{

public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
require_once('./tests/Mock/Output.php');
}
Expand Down
5 changes: 3 additions & 2 deletions tests/validate_composer_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Phpbb\Epv\Output\OutputInterface;
use Phpbb\Epv\Tests\Mock\Output;
use Phpbb\Epv\Tests\Tests\epv_test_validate_composer;
use PHPUnit\Framework\TestCase;

/**
*
Expand All @@ -15,9 +16,9 @@
*
*/

class validate_composer_test extends PHPUnit_Framework_TestCase
class validate_composer_test extends TestCase
{
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
require_once('./tests/Mock/Output.php');
}
Expand Down
5 changes: 3 additions & 2 deletions tests/validate_directory_structure_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Phpbb\Epv\Output\OutputInterface;
use Phpbb\Epv\Tests\Tests\epv_test_validate_directory_structure;
use PHPUnit\Framework\TestCase;

/**
*
Expand All @@ -12,7 +13,7 @@
*
*/

class validate_directory_structure_test extends PHPUnit_Framework_TestCase {
class validate_directory_structure_test extends TestCase {
public function test_missing_license() {
$output = $this->getOutputMock();
$output->expects(self::once())
Expand Down Expand Up @@ -86,7 +87,7 @@ public function test_composer_wrong() {
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|OutputInterface
* @return PHPUnit\Framework\MockObject\MockObject|OutputInterface
*/
function getOutputMock()
{
Expand Down
7 changes: 4 additions & 3 deletions tests/validate_languages_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@

use Phpbb\Epv\Output\OutputInterface;
use Phpbb\Epv\Tests\Tests\epv_test_validate_languages;
use PHPUnit\Framework\TestCase;

class validate_languages_test extends PHPUnit_Framework_TestCase
class validate_languages_test extends TestCase
{
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
require_once('./tests/Mock/Output.php');
}

public function test_languages() {
/** @var OutputInterface|PHPUnit_Framework_MockObject_MockObject $output */
/** @var OutputInterface|PHPUnit\Framework\MockObject\MockObject\MockObject $output */
$output = $this->createMock(OutputInterface::class);

$output
Expand Down
11 changes: 6 additions & 5 deletions tests/validate_license_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

use Phpbb\Epv\Output\OutputInterface;
use Phpbb\Epv\Tests\Tests\epv_test_validate_directory_structure;
use PHPUnit\Framework\TestCase;

class validate_license_test extends PHPUnit_Framework_TestCase
class validate_license_test extends TestCase
{
/**
* @param string $license
Expand All @@ -33,7 +34,7 @@ public function test_license_gpl_2_0_skeleton()
{
$this->validateLicense('gpl-2.0-skeleton-ext', function($output)
{
/** @var PHPUnit_Framework_MockObject_MockObject $output */
/** @var PHPUnit\Framework\MockObject\MockObject $output */
$output
->expects($this->never())
->method('addMessage')
Expand All @@ -45,7 +46,7 @@ public function test_license_gpl_2_0_with_appendix()
{
$this->validateLicense('gpl-2.0-with-appendix', function($output)
{
/** @var PHPUnit_Framework_MockObject_MockObject $output */
/** @var PHPUnit\Framework\MockObject\MockObject $output */
$output
->expects($this->never())
->method('addMessage')
Expand All @@ -57,7 +58,7 @@ public function test_license_gpl_3_0()
{
$this->validateLicense('gpl-3.0', function($output)
{
/** @var PHPUnit_Framework_MockObject_MockObject $output */
/** @var PHPUnit\Framework\MockObject\MockObject $output */
$output
->expects($this->once())
->method('addMessage')
Expand All @@ -70,7 +71,7 @@ public function test_license_apache_2_0()
{
$this->validateLicense('apache-2.0', function($output)
{
/** @var PHPUnit_Framework_MockObject_MockObject $output */
/** @var PHPUnit\Framework\MockObject\MockObject $output */
$output
->expects($this->once())
->method('addMessage')
Expand Down
11 changes: 6 additions & 5 deletions tests/validate_revert_schema_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
use Phpbb\Epv\Output\OutputInterface;
use Phpbb\Epv\Tests\Mock\Output;
use Phpbb\Epv\Tests\Tests\epv_test_validate_revert_schema;
use PHPUnit\Framework\TestCase;

class validate_revert_schema_test extends PHPUnit_Framework_TestCase
class validate_revert_schema_test extends TestCase
{
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
require_once('./tests/Mock/Output.php');
}
Expand All @@ -41,7 +42,7 @@ public function test_missing_update_schema()
{
$this->validateFile('tests/testFiles/migrations/missing_update_schema.php', function($output)
{
/** @var PHPUnit_Framework_MockObject_MockObject $output */
/** @var PHPUnit\Framework\MockObject\MockObject $output */
$output->expects($this->never())
->method('addMessage');
});
Expand All @@ -51,7 +52,7 @@ public function test_existing_revert_schema()
{
$this->validateFile('tests/testFiles/migrations/existing_revert_schema.php', function($output)
{
/** @var PHPUnit_Framework_MockObject_MockObject $output */
/** @var PHPUnit\Framework\MockObject\MockObject $output */
$output->expects($this->never())
->method('addMessage');
});
Expand All @@ -61,7 +62,7 @@ public function test_missing_revert_schema()
{
$this->validateFile('tests/testFiles/migrations/missing_revert_schema.php', function($output)
{
/** @var PHPUnit_Framework_MockObject_MockObject $output */
/** @var PHPUnit\Framework\MockObject\MockObject $output */
$output->expects($this->once())
->method('addMessage')
->with(OutputInterface::ERROR, 'Migration file tests/testFiles/migrations/missing_revert_schema.php is missing the revert_schema() method.');
Expand Down
9 changes: 5 additions & 4 deletions tests/validate_service_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
use Phpbb\Epv\Tests\Mock\Output;
use Phpbb\Epv\Output\OutputInterface;
use Phpbb\Epv\Tests\Tests\epv_test_validate_service;
use PHPUnit\Framework\TestCase;

class validate_service_test extends PHPUnit_Framework_TestCase
class validate_service_test extends TestCase
{
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
require_once('./tests/Mock/Output.php');
}
Expand Down Expand Up @@ -54,7 +55,7 @@ public function test_good_service_names($config)
{
$this->validateConfig($config, function($output)
{
/** @var PHPUnit_Framework_MockObject_MockObject $output */
/** @var PHPUnit\Framework\MockObject\MockObject $output */
$output
->expects($this->never())
->method('addMessage')
Expand All @@ -77,7 +78,7 @@ public function bad_service_names_data()
public function test_bad_service_names($config, $expected)
{
$this->validateConfig($config, function($output) use ($expected) {
/** @var PHPUnit_Framework_MockObject_MockObject $output */
/** @var PHPUnit\Framework\MockObject\MockObject $output */
$output
->expects($this->exactly(4))
->method('addMessage')
Expand Down
5 changes: 3 additions & 2 deletions tests/validate_sql_queries_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Phpbb\Epv\Output\OutputInterface;
use Phpbb\Epv\Tests\Mock\Output;
use Phpbb\Epv\Tests\Tests\epv_test_validate_sql_queries;
use PHPUnit\Framework\TestCase;

/**
*
Expand All @@ -14,9 +15,9 @@
*
*/

class validate_sql_queries_test extends PHPUnit_Framework_TestCase
class validate_sql_queries_test extends TestCase
{
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
require_once('./tests/Mock/Output.php');
}
Expand Down

0 comments on commit 677d306

Please sign in to comment.