Skip to content

Commit

Permalink
Merge pull request #17 from iMattPro/updates
Browse files Browse the repository at this point in the history
Clean up test files
  • Loading branch information
iMattPro authored Jan 2, 2025
2 parents 6931699 + abd4d4a commit 0b1bb6a
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 27 deletions.
12 changes: 6 additions & 6 deletions tests/unit/acp_module_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@

namespace phpbb\pwakit\tests\unit;

use Symfony\Component\DependencyInjection\ContainerInterface;
use p_master;
use phpbb\cache\driver\dummy;
use phpbb\db\driver\driver_interface;
use phpbb\module\module_manager;
use phpbb_mock_event_dispatcher;
use phpbb_mock_extension_manager;
use phpbb\pwakit\acp\pwa_acp_module;
use phpbb\pwakit\controller\admin_controller;
use phpbb\request\request;
use phpbb\template\template;
use phpbb_mock_event_dispatcher;
use phpbb_mock_extension_manager;
use phpbb_test_case;
use Symfony\Component\DependencyInjection\ContainerInterface;
use phpbb\pwakit\controller\admin_controller;
use phpbb\pwakit\acp\pwa_acp_module;
use phpbb\db\driver\driver_interface;

require_once __DIR__ . '/../../../../../includes/functions_module.php';

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/admin_controller_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace phpbb\pwakit\controller;

use PHPUnit\Framework\MockObject\MockObject;
use phpbb\config\config;
use phpbb\exception\runtime_exception;
use phpbb\language\language;
Expand All @@ -20,7 +21,6 @@
use phpbb\request\request_interface;
use phpbb\template\template;
use phpbb_test_case;
use PHPUnit\Framework\MockObject\MockObject;

class admin_controller_test extends phpbb_test_case
{
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/event_listener_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@

namespace phpbb\pwakit\tests\unit;

use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use phpbb\config\config;
use phpbb\event\data;
use phpbb\pwakit\event\main_listener;
use phpbb\pwakit\helper\helper;
use phpbb\template\template;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use phpbb_test_case;

class event_listener_test extends \phpbb_test_case
class event_listener_test extends phpbb_test_case
{
/** @var config */
protected config $config;
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/ext_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

namespace phpbb\pwakit\tests\unit;

use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\DependencyInjection\ContainerInterface;
use phpbb\config\config;
use phpbb\db\migrator;
use phpbb\filesystem\exception\filesystem_exception;
Expand All @@ -19,8 +21,6 @@
use phpbb\pwakit\ext;
use phpbb_mock_user;
use phpbb_test_case;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\DependencyInjection\ContainerInterface;

class ext_test extends phpbb_test_case
{
Expand Down
34 changes: 22 additions & 12 deletions tests/unit/helper_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,27 @@
namespace phpbb\pwakit\tests\unit;

use FastImageSize\FastImageSize;
use PHPUnit\DbUnit\DataSet\DefaultDataSet;
use PHPUnit\DbUnit\DataSet\IDataSet;
use PHPUnit\DbUnit\DataSet\XmlDataSet;
use PHPUnit\Framework\MockObject\MockObject;
use phpbb\cache\driver\driver_interface as cache;
use phpbb\config\config;
use phpbb\di\service_collection;
use phpbb\exception\runtime_exception;
use phpbb\filesystem\filesystem;
use phpbb\pwakit\helper\helper;
use phpbb\pwakit\storage\storage;
use phpbb\storage\adapter\local as adapter_local;
use phpbb\storage\adapter_factory;
use phpbb\storage\provider\local as provider_local;
use phpbb\storage\state_helper;
use phpbb\template\template;
use PHPUnit\Framework\MockObject\MockObject;
use phpbb_database_test_case;
use phpbb_mock_container_builder;
use phpbb_mock_extension_manager;

class helper_test extends \phpbb_database_test_case
class helper_test extends phpbb_database_test_case
{
protected const FIXTURES = __DIR__ . '/../fixtures/';

Expand All @@ -47,7 +57,7 @@ protected static function setup_extensions(): array
return array('phpbb/pwakit');
}

protected function getDataSet()
protected function getDataSet(): IDataSet|XmlDataSet|DefaultDataSet
{
return $this->createXMLDataSet(self::FIXTURES . 'storage.xml');
}
Expand All @@ -63,36 +73,36 @@ protected function setUp(): void
$this->storage_path = 'ext/phpbb/pwakit/tests/fixtures/site_icons';

$this->config = new config([
'storage\phpbb_pwakit\provider' => 'phpbb\\storage\\provider\\local',
'storage\phpbb_pwakit\provider' => provider_local::class,
'storage\phpbb_pwakit\config\path' => $this->storage_path
]);

$phpbb_extension_manager = new \phpbb_mock_extension_manager($phpbb_root_path);
$phpbb_extension_manager = new phpbb_mock_extension_manager($phpbb_root_path);

$cache = $this->createMock('\phpbb\cache\driver\driver_interface');
$cache = $this->createMock(cache::class);

$db = $this->new_dbal();

$phpbb_container = new \phpbb_mock_container_builder();
$phpbb_container = new phpbb_mock_container_builder();

$storage_provider = new \phpbb\storage\provider\local();
$storage_provider = new provider_local();
$phpbb_container->set('storage.provider.local', $storage_provider);
$provider_collection = new service_collection($phpbb_container);
$provider_collection->add('storage.provider.local');
$provider_collection->add_service_class('storage.provider.local', 'phpbb\storage\provider\local');
$provider_collection->add_service_class('storage.provider.local', provider_local::class);

$adapter_local = new \phpbb\storage\adapter\local(new filesystem(), $phpbb_root_path);
$adapter_local = new adapter_local(new filesystem(), $phpbb_root_path);
$phpbb_container->set('storage.adapter.local', $adapter_local);
$adapter_collection = new service_collection($phpbb_container);
$adapter_collection->add('storage.adapter.local');
$adapter_collection->add_service_class('storage.adapter.local', 'phpbb\storage\adapter\local');
$adapter_collection->add_service_class('storage.adapter.local', adapter_local::class);

$adapter_factory = new adapter_factory(
$this->config,
$adapter_collection,
$provider_collection
);
$state_helper = $this->getMockBuilder('\phpbb\storage\state_helper')
$state_helper = $this->getMockBuilder(state_helper::class)
->disableOriginalConstructor()
->getMock();

Expand Down
7 changes: 4 additions & 3 deletions tests/unit/upload_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@

namespace phpbb\pwakit\tests\unit;

use PHPUnit\Framework\MockObject\MockObject;
use phpbb\exception\runtime_exception;
use phpbb\files\filespec_storage;
use phpbb\files\upload as files_upload;
use phpbb\pwakit\helper\upload;
use phpbb\storage\storage;
use PHPUnit\Framework\MockObject\MockObject;
use phpbb\exception\runtime_exception;
use phpbb_test_case;

class upload_test extends \phpbb_test_case
class upload_test extends phpbb_test_case
{
protected MockObject|\phpbb\files\upload $files_upload;
protected MockObject|filespec_storage $file;
Expand Down

0 comments on commit 0b1bb6a

Please sign in to comment.