diff --git a/.gitignore b/.gitignore index 6829678390..f36b1eb657 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ tagfile /tests/reports /web .phpunit.result.cache +.phpunit.cache docs/build diff --git a/composer.json b/composer.json index 16d97e87e7..82872af8b1 100644 --- a/composer.json +++ b/composer.json @@ -27,13 +27,13 @@ "getdkan/pdlt": "^0.1.7", "getdkan/procrastinator": "^5.0.3", "getdkan/rooted-json-data": "^0.2.2", - "guzzlehttp/guzzle": "^6.5.8 || ^7.4.5", + "guzzlehttp/guzzle": "^6.5.8 || ^7", "ilbee/csv-response": "^1.2.0", "justinrainbow/json-schema": "^5.2", "m1x0n/opis-json-schema-error-presenter": "^0.5.3", - "npm-asset/select2": "^4.0", + "npm-asset/select2": "^4.0 || dev-develop", "oomphinc/composer-installers-extender": "^2.0", - "ramsey/uuid": "^3.8.0", + "ramsey/uuid": "^3.8.0 || ^4", "stolt/json-merge-patch": "^2.0", "symfony/polyfill-php80": "^1.27" }, diff --git a/dkan.info.yml b/dkan.info.yml index e8af44d0d9..857bf97b7e 100644 --- a/dkan.info.yml +++ b/dkan.info.yml @@ -1,7 +1,7 @@ name: DKAN description: 'DKAN Open Data Portal' type: module -core_version_requirement: ^10 +core_version_requirement: ^10 || ^11 package: DKAN dependencies: - dkan:metastore diff --git a/modules/common/common.info.yml b/modules/common/common.info.yml index bf58a27d38..763bb84092 100644 --- a/modules/common/common.info.yml +++ b/modules/common/common.info.yml @@ -1,5 +1,5 @@ name: Common description: Provides common utilities, functions, and base api endpoints used by other DKAN modules. type: module -core_version_requirement: ^10 +core_version_requirement: ^10 || ^11 package: DKAN diff --git a/modules/common/src/LoggerTrait.php b/modules/common/src/LoggerTrait.php deleted file mode 100644 index b1b0461ec8..0000000000 --- a/modules/common/src/LoggerTrait.php +++ /dev/null @@ -1,123 +0,0 @@ -loggerName = $name; - } - - /** - * Setter. - * - * @param \Drupal\Core\Logger\LoggerChannelFactory $loggerService - * Injected logger factory service. - */ - public function setLoggerFactory(LoggerChannelFactory $loggerService) { - $this->loggerService = $loggerService; - } - - /** - * Private. - */ - protected function log($loggerName, $message, $variables = [], $level = LogLevel::ERROR) { - if ($this->loggerService) { - $this->loggerService->get($loggerName)->log($level, $message, $variables); - } - } - - /** - * Private. - */ - protected function error(string $message, array $context = []) { - - if ($this->loggerService) { - $this->loggerService->get($this->loggerName)->error($message, $context); - } - } - - /** - * Private. - */ - protected function warning(string $message, array $context = []) { - - if ($this->loggerService) { - $this->loggerService->get($this->loggerName)->warning($message, $context); - } - } - - /** - * Private. - */ - protected function notice(string $message, array $context = []) { - - if ($this->loggerService) { - $this->loggerService->get($this->loggerName)->notice($message, $context); - } - } - - /** - * Private. - */ - private function showDebug() { - $this->debug = TRUE; - } - - /** - * Private. - */ - private function debug(string $message = "", array $context = []) { - if ($this->loggerService && $this->debug) { - $m = "@class @function: " . $message; - $c = array_merge($context, - [ - '@class' => static::class, - '@function' => debug_backtrace()[1]['function'], - '@message' => $message, - ] - ); - - $this->loggerService->get($this->loggerName)->notice($m, $c); - } - } - -} diff --git a/modules/common/tests/src/Traits/LoggerTraitTest.php b/modules/common/tests/src/Traits/LoggerTraitTest.php deleted file mode 100644 index 32db7e7c8b..0000000000 --- a/modules/common/tests/src/Traits/LoggerTraitTest.php +++ /dev/null @@ -1,84 +0,0 @@ -getLoggerChain(); - $this->setLoggerFactory($logger->getMock()); - - $context = ['foo' => 'bar']; - $this->log('log name', 'message', $context, 'critical'); - - $this->assertEquals('log name', $logger->getStoredInput('names')[0]); - $this->assertEquals('critical', $logger->getStoredInput('logs')[0]); - $this->assertEquals('message', $logger->getStoredInput('logs')[1]); - $this->assertEquals($context, $logger->getStoredInput('logs')[2]); - } - - /** - * - */ - public function testError() { - $logger = $this->getLoggerChain(); - $this->setLoggerFactory($logger->getMock()); - - $this->error('some error'); - - $this->assertEquals('some error', $logger->getStoredInput('errors')[0]); - } - - /** - * - */ - public function testWarning() { - $logger = $this->getLoggerChain(); - $this->setLoggerFactory($logger->getMock()); - - $this->warning('some warning'); - - $this->assertEquals('some warning', $logger->getStoredInput('warnings')[0]); - } - - /** - * - */ - public function testNotice() { - $logger = $this->getLoggerChain(); - $this->setLoggerFactory($logger->getMock()); - - $this->notice('some notice'); - - $this->assertEquals('some notice', $logger->getStoredInput('notices')[0]); - } - - /** - * Getter. - */ - public function getLoggerChain() { - return (new Chain($this)) - ->add(LoggerChannelFactory::class, 'get', LoggerChannelInterface::class, "names") - ->add(LoggerChannelInterface::class, 'log', NULL, "logs") - ->add(LoggerChannelInterface::class, 'error', NULL, "errors") - ->add(LoggerChannelInterface::class, 'warning', NULL, "warnings") - ->add(LoggerChannelInterface::class, 'notice', NULL, "notices"); - } - -} diff --git a/modules/common/tests/src/Unit/Connection.php b/modules/common/tests/src/Unit/Connection.php index 4ed9b25d73..d99ab9b554 100644 --- a/modules/common/tests/src/Unit/Connection.php +++ b/modules/common/tests/src/Unit/Connection.php @@ -27,6 +27,10 @@ class Connection extends CoreConnection { */ protected $statementClass; + public function upsert($table, array $options = []) { } + + public function schema() { } + /** * {@inheritdoc} */ diff --git a/modules/common/tests/src/Unit/Events/EventTest.php b/modules/common/tests/src/Unit/Events/EventTest.php index 7ddf3297a0..5617a435bb 100644 --- a/modules/common/tests/src/Unit/Events/EventTest.php +++ b/modules/common/tests/src/Unit/Events/EventTest.php @@ -4,10 +4,10 @@ use Drupal\common\EventDispatcherTrait; use Drupal\common\Events\Event; -use Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher; use MockChain\Chain; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\EventDispatcher\EventDispatcher; class EventTest extends TestCase { @@ -19,7 +19,7 @@ public function testDataIntegrityAcrossEventSubscribers() { ->add(Container::class) ->getMock(); - $dispatcher = new ContainerAwareEventDispatcher($containerx); + $dispatcher = new EventDispatcher($containerx); $dispatcher->addListener('test_event', function(Event $event) { $event->setData(1); }); diff --git a/modules/common/tests/src/Unit/LoggerTraitTest.php b/modules/common/tests/src/Unit/LoggerTraitTest.php deleted file mode 100644 index c76a0fb942..0000000000 --- a/modules/common/tests/src/Unit/LoggerTraitTest.php +++ /dev/null @@ -1,30 +0,0 @@ -add(LoggerChannelFactory::class) - ->getMock(); - - $class = new Logging(); - $class->setLoggerName('blah'); - $class->setLoggerFactory($loggerChannelFactory); - $class->do(); - $this->assertTrue(TRUE); - } - -} diff --git a/modules/common/tests/src/Unit/Storage/QueryDataProvider.php b/modules/common/tests/src/Unit/Storage/QueryDataProvider.php index 8c217f5e30..24c0d6ab29 100644 --- a/modules/common/tests/src/Unit/Storage/QueryDataProvider.php +++ b/modules/common/tests/src/Unit/Storage/QueryDataProvider.php @@ -24,7 +24,7 @@ class QueryDataProvider { /** * */ - public function getAllData($return): array { + public static function getAllData(): array { $tests = [ 'noPropertiesQuery', 'propertiesQuery', diff --git a/modules/data_dictionary_widget/data_dictionary_widget.info.yml b/modules/data_dictionary_widget/data_dictionary_widget.info.yml index f542fab1aa..5189ecc556 100644 --- a/modules/data_dictionary_widget/data_dictionary_widget.info.yml +++ b/modules/data_dictionary_widget/data_dictionary_widget.info.yml @@ -2,7 +2,7 @@ name: 'Data Dictionary Widget' description: 'Provides a field widget to generate a data-dictionary form' package: DKAN type: module -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^9.4 || ^10 || ^11 dependencies: - drupal:field - metastore diff --git a/modules/datastore/datastore.info.yml b/modules/datastore/datastore.info.yml index 772b466c4b..f48e0ec854 100755 --- a/modules/datastore/datastore.info.yml +++ b/modules/datastore/datastore.info.yml @@ -1,7 +1,7 @@ name: Datastore description: Provides integration with the datastore library. type: module -core_version_requirement: ^10 +core_version_requirement: ^10 || ^11 package: DKAN dependencies: - dkan:common diff --git a/modules/datastore/modules/datastore_mysql_import/datastore_mysql_import.info.yml b/modules/datastore/modules/datastore_mysql_import/datastore_mysql_import.info.yml index 3e2c64fafb..11cb69334e 100755 --- a/modules/datastore/modules/datastore_mysql_import/datastore_mysql_import.info.yml +++ b/modules/datastore/modules/datastore_mysql_import/datastore_mysql_import.info.yml @@ -1,7 +1,7 @@ name: Datastore MySQL Import description: Provides a MySQL Importer class. type: module -core_version_requirement: ^10 +core_version_requirement: ^10 || ^11 package: DKAN configure: datastore.mysql_import.settings dependencies: diff --git a/modules/datastore/tests/src/Kernel/Service/PostImportTest.php b/modules/datastore/tests/src/Kernel/Service/PostImportTest.php index a69b85fa6e..5947e9fb9c 100644 --- a/modules/datastore/tests/src/Kernel/Service/PostImportTest.php +++ b/modules/datastore/tests/src/Kernel/Service/PostImportTest.php @@ -2,9 +2,11 @@ namespace Drupal\Tests\datastore\Kernel\Service; -use Drupal\Core\Database\Connection; +use Drupal\Core\Database\Query\SelectInterface; +use Drupal\Core\Database\StatementInterface; use Drupal\KernelTests\KernelTestBase; use Drupal\datastore\Service\PostImport; +use Drupal\sqlite\Driver\Database\sqlite\Connection as SqliteConnection; /** * Tests the PostImport service. @@ -29,10 +31,10 @@ class PostImportTest extends KernelTestBase { */ public function testRetrieveJobStatusException() { // Mock a connection to explode. - $connection = $this->getMockBuilder(Connection::class) - ->disableOriginalConstructor() + $connection = $this->getMockBuilder(SqliteConnection::class) + ->setConstructorArgs([$this->createStub(\PDO::class), []]) ->onlyMethods(['select']) - ->getMockForAbstractClass(); + ->getMock(); $connection->expects($this->any()) ->method('select') ->willThrowException(new \Exception()); @@ -49,14 +51,30 @@ public function testRetrieveJobStatusException() { * @covers ::removeJobStatus */ public function testRemoveJobStatusException() { + + $statement = $this->createStub(StatementInterface::class); + $statement->method('fetchAssoc') + ->willReturn(FALSE); + + $select = $this->createStub(SelectInterface::class); + $select->method('condition') + ->willReturn($select); + $select->method('fields') + ->willReturn($select); + $select->method('execute') + ->willReturn($statement); + // Mock a connection to explode. - $connection = $this->getMockBuilder(Connection::class) - ->disableOriginalConstructor() - ->onlyMethods(['delete']) - ->getMockForAbstractClass(); + $connection = $this->getMockBuilder(SqliteConnection::class) + ->setConstructorArgs([$this->createStub(\PDO::class), []]) + ->onlyMethods(['delete', 'select']) + ->getMock(); $connection->expects($this->any()) ->method('delete') ->willThrowException(new \Exception()); + $connection->expects($this->any()) + ->method('select') + ->willReturn($select); $post_import = new PostImport( $connection, diff --git a/modules/datastore/tests/src/Unit/Controller/QueryDownloadControllerTest.php b/modules/datastore/tests/src/Unit/Controller/QueryDownloadControllerTest.php index d95534078f..15ab60bfc4 100644 --- a/modules/datastore/tests/src/Unit/Controller/QueryDownloadControllerTest.php +++ b/modules/datastore/tests/src/Unit/Controller/QueryDownloadControllerTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\datastore\Unit\Controller; -use Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher; use Drupal\Core\Cache\Context\CacheContextsManager; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ImmutableConfig; @@ -24,6 +23,7 @@ use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; /** @@ -40,7 +40,7 @@ protected function setUp(): void { // Set cache services $options = (new Options) ->add('cache_contexts_manager', CacheContextsManager::class) - ->add('event_dispatcher', ContainerAwareEventDispatcher::class) + ->add('event_dispatcher', EventDispatcher::class) ->index(0); $chain = (new Chain($this)) ->add(ContainerInterface::class, 'get', $options) diff --git a/modules/datastore/tests/src/Unit/DataDictionary/AlterTableQuery/MySQLQueryTest.php b/modules/datastore/tests/src/Unit/DataDictionary/AlterTableQuery/MySQLQueryTest.php index c4d4aa1683..a25a173d5a 100644 --- a/modules/datastore/tests/src/Unit/DataDictionary/AlterTableQuery/MySQLQueryTest.php +++ b/modules/datastore/tests/src/Unit/DataDictionary/AlterTableQuery/MySQLQueryTest.php @@ -47,7 +47,9 @@ public function setUp(): void { */ public function buildConnectionChain(): Chain { return (new Chain($this)) + // Drupal 10 will call getDriverClass, while 11 will call update directly. ->add(Connection::class, 'getDriverClass', UpdateQueryMock::class) + ->add(Connection::class, 'update', UpdateQueryMock::class) ->add(Connection::class, 'prepareStatement', StatementInterface::class, 'prepare') ->add(Connection::class, 'query', StatementInterface::class) ->add(StatementInterface::class, 'execute', TRUE) diff --git a/modules/datastore/tests/src/Unit/DatastoreServiceTest.php b/modules/datastore/tests/src/Unit/DatastoreServiceTest.php index 302567b0e2..76e12b85fe 100644 --- a/modules/datastore/tests/src/Unit/DatastoreServiceTest.php +++ b/modules/datastore/tests/src/Unit/DatastoreServiceTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\datastore\Unit; -use Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher; use Drupal\Core\Queue\QueueFactory; use Drupal\datastore\Plugin\QueueWorker\ImportJob; use Drupal\datastore\Storage\ImportJobStoreFactory; @@ -25,6 +24,7 @@ use PHPUnit\Framework\TestCase; use Procrastinator\Result; use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\EventDispatcher\EventDispatcher; /** * @covers \Drupal\datastore\DatastoreService @@ -52,7 +52,7 @@ public function testImport() { ->add(ImportService::class, 'getImporter', ImportJob::class) ->add(ImportJob::class, 'getResult', new Result()) ->add(QueueFactory::class, "get", NULL) - ->add(ContainerAwareEventDispatcher::class, "dispatch", NULL); + ->add(EventDispatcher::class, "dispatch", NULL); $service = DatastoreService::create($chain->getMock()); $result = $service->import("1"); @@ -100,7 +100,7 @@ public function testGetDataDictionaryFields() { private function getCommonChain() { $options = (new Options()) - ->add('event_dispatcher', ContainerAwareEventDispatcher::class) + ->add('event_dispatcher', EventDispatcher::class) ->add('dkan.metastore.resource_mapper', ResourceMapper::class) ->add('dkan.datastore.service.resource_localizer', ResourceLocalizer::class) ->add('dkan.datastore.service.factory.import', ImportServiceFactory::class) diff --git a/modules/datastore/tests/src/Unit/Service/PostImportTest.php b/modules/datastore/tests/src/Unit/Service/PostImportTest.php index 6281387e10..8cc4240e93 100644 --- a/modules/datastore/tests/src/Unit/Service/PostImportTest.php +++ b/modules/datastore/tests/src/Unit/Service/PostImportTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\datastore\Unit\Service; use Drupal\Core\Database\Connection; +use Drupal\Core\Database\Query\Select; use Drupal\metastore\ResourceMapper; use Drupal\datastore\Service\PostImport; use PHPUnit\Framework\TestCase; @@ -42,43 +43,44 @@ class PostImportTest extends TestCase { */ public function testStoreJobStatus() { - $connectionMock = $this->getMockBuilder(Connection::class) - ->disableOriginalConstructor() - ->getMock(); + $connectionMock = $this->getMockBuilder(Connection::class) + ->disableOriginalConstructor() + ->getMock(); - $resourceMapperMock = $this->getMockBuilder(ResourceMapper::class) - ->disableOriginalConstructor() - ->getMock(); + $resourceMapperMock = $this->getMockBuilder(ResourceMapper::class) + ->disableOriginalConstructor() + ->getMock(); - $queryMock = $this->getMockBuilder('stdClass') - ->addMethods(['fields', 'execute']) - ->getMock(); + $queryMock = $this->getMockBuilder(Select::class) + ->disableOriginalConstructor() + ->onlyMethods(['fields', 'execute']) + ->getMock(); - $connectionMock->expects($this->once()) - ->method('insert') - ->with('dkan_post_import_job_status') - ->willReturn($queryMock); + $connectionMock->expects($this->once()) + ->method('insert') + ->with('dkan_post_import_job_status') + ->willReturn($queryMock); - $queryMock->expects($this->once()) - ->method('fields') - ->with([ - 'resource_identifier' => 'test_identifier', - 'resource_version' => 'test_version', - 'post_import_status' => 'test_status', - 'post_import_error' => 'test_error', - ]) - ->willReturnSelf(); + $queryMock->expects($this->once()) + ->method('fields') + ->with([ + 'resource_identifier' => 'test_identifier', + 'resource_version' => 'test_version', + 'post_import_status' => 'test_status', + 'post_import_error' => 'test_error', + ]) + ->willReturnSelf(); - $queryMock->expects($this->once()) - ->method('execute') - ->willReturn(TRUE); + $queryMock->expects($this->once()) + ->method('execute') + ->willReturn(TRUE); - $postImport = new PostImport($connectionMock, $resourceMapperMock); + $postImport = new PostImport($connectionMock, $resourceMapperMock); - $result_store = $postImport->storeJobStatus('test_identifier', 'test_version', 'test_status', 'test_error'); + $result_store = $postImport->storeJobStatus('test_identifier', 'test_version', 'test_status', 'test_error'); - // Assert that the method returned the expected result. - $this->assertTrue($result_store); + // Assert that the method returned the expected result. + $this->assertTrue($result_store); } } diff --git a/modules/datastore/tests/src/Unit/SqlEndpoint/WebServiceApiTest.php b/modules/datastore/tests/src/Unit/SqlEndpoint/WebServiceApiTest.php index 8e15f6117a..b95a8b76f5 100644 --- a/modules/datastore/tests/src/Unit/SqlEndpoint/WebServiceApiTest.php +++ b/modules/datastore/tests/src/Unit/SqlEndpoint/WebServiceApiTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\datastore\Unit\SqlEndpoint; -use Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher; use Drupal\Core\Cache\Context\CacheContextsManager; use Drupal\Core\Config\Config; use Drupal\Core\Config\ConfigFactory; @@ -18,6 +17,7 @@ use Drupal\metastore\NodeWrapper\NodeDataFactory; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; @@ -37,7 +37,7 @@ protected function setUp(): void { // Set cache services $options = (new Options) ->add('cache_contexts_manager', CacheContextsManager::class) - ->add('event_dispatcher', ContainerAwareEventDispatcher::class) + ->add('event_dispatcher', EventDispatcher::class) ->index(0); $chain = (new Chain($this)) ->add(ContainerInterface::class, 'get', $options) @@ -102,7 +102,7 @@ public function getCommonMockChain($query = "[SELECT * FROM 123__456][WHERE abc ->add('dkan.metastore.api_response', MetastoreApiResponse::class) ->add("database", Connection::class) ->add('request_stack', RequestStack::class) - ->add('event_dispatcher', ContainerAwareEventDispatcher::class) + ->add('event_dispatcher', EventDispatcher::class) ->add('cache_contexts_manager', CacheContextsManager::class) ->index(0); @@ -110,11 +110,15 @@ public function getCommonMockChain($query = "[SELECT * FROM 123__456][WHERE abc $row = (object) ['column_1' => "hello", 'column_2' => "goodbye"]; + $request = $this->getMockBuilder(Request::class) + ->onlyMethods(['get', 'getContent']) + ->getMock(); + $request->method('get')->willReturn($query); + $request->method('getContent')->willReturn($body); + return (new Chain($this)) ->add(Container::class, "get", $options) - ->add(RequestStack::class, 'getCurrentRequest', Request::class) - ->add(Request::class, 'get', $query) - ->add(Request::class, 'getContent', $body) + ->add(RequestStack::class, 'getCurrentRequest', $request) ->add(ConfigFactory::class, 'get', Config::class) ->add(Config::class, 'get', 1000) ->add(DatastoreSqlEndpointService::class, 'runQuery', [$row]) diff --git a/modules/datastore/tests/src/Unit/Storage/DatabaseTableFactoryTest.php b/modules/datastore/tests/src/Unit/Storage/DatabaseTableFactoryTest.php index 614d60e5f7..fc7b982512 100644 --- a/modules/datastore/tests/src/Unit/Storage/DatabaseTableFactoryTest.php +++ b/modules/datastore/tests/src/Unit/Storage/DatabaseTableFactoryTest.php @@ -2,10 +2,10 @@ namespace Drupal\Tests\datastore\Unit\Storage; -use Drupal\Core\Database\Connection; use Drupal\datastore\DatastoreResource; use Drupal\datastore\Storage\DatabaseTable; use Drupal\datastore\Storage\DatabaseTableFactory; +use Drupal\sqlite\Driver\Database\sqlite\Connection; use MockChain\Chain; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; @@ -21,8 +21,9 @@ class DatabaseTableFactoryTest extends TestCase { * Test basic function (no indexer service). */ public function test() { - $connection = (new Chain($this)) - ->add(Connection::class, "__destruct", NULL) + $connection = $this->getMockBuilder(Connection::class) + ->disableOriginalConstructor() + ->onlyMethods([]) ->getMock(); $databaseTable = (new Chain($this)) @@ -31,9 +32,9 @@ public function test() { $builder = $this->getMockBuilder(DatabaseTableFactory::class); $factory = $builder->setConstructorArgs([ - $connection, - $this->createStub(LoggerInterface::class - )]) + $connection, + $this->createStub(LoggerInterface::class), + ]) ->onlyMethods(["getDatabaseTable"]) ->getMock(); diff --git a/modules/datastore/tests/src/Unit/Storage/DatabaseTableTest.php b/modules/datastore/tests/src/Unit/Storage/DatabaseTableTest.php index e936432e80..a437462dcf 100644 --- a/modules/datastore/tests/src/Unit/Storage/DatabaseTableTest.php +++ b/modules/datastore/tests/src/Unit/Storage/DatabaseTableTest.php @@ -6,8 +6,8 @@ use Drupal\Core\Database\DatabaseExceptionWrapper; use Drupal\Core\Database\Query\Insert; use Drupal\Core\Database\Query\Select; -use Drupal\Core\Database\StatementWrapper; use Drupal\common\Storage\Query; +use Drupal\Core\Database\StatementInterface; use Drupal\datastore\DatastoreResource; use Drupal\datastore\Storage\DatabaseTable; use Drupal\mysql\Driver\Database\mysql\Schema; @@ -104,8 +104,8 @@ public function testRetrieveAll() { $connection = $this->getConnectionChain() ->add(Connection::class, "select", Select::class) ->add(Select::class, "fields", Select::class) - ->add(Select::class, "execute", StatementWrapper::class) - ->add(StatementWrapper::class, 'fetchAll', $sequence) + ->add(Select::class, "execute", StatementInterface::class) + ->add(StatementInterface::class, 'fetchAll', $sequence) ->getMock(); $databaseTable = new DatabaseTable( @@ -128,8 +128,8 @@ public function testStore() { ->add(Connection::class, 'select', Select::class, 'select_1') ->add(Select::class, 'fields', Select::class) ->add(Select::class, 'condition', Select::class) - ->add(Select::class, 'execute', StatementWrapper::class) - ->add(StatementWrapper::class, 'fetch', NULL); + ->add(Select::class, 'execute', StatementInterface::class) + ->add(StatementInterface::class, 'fetch', NULL); $databaseTable = new DatabaseTable( $connectionChain->getMock(), @@ -151,8 +151,8 @@ public function testStoreFieldCountException() { ->add(Connection::class, 'select', Select::class, 'select_1') ->add(Select::class, 'fields', Select::class) ->add(Select::class, 'condition', Select::class) - ->add(Select::class, 'execute', StatementWrapper::class) - ->add(StatementWrapper::class, 'fetch', NULL); + ->add(Select::class, 'execute', StatementInterface::class) + ->add(StatementInterface::class, 'fetch', NULL); $databaseTable = new DatabaseTable( $connectionChain->getMock(), @@ -175,8 +175,8 @@ public function testStoreMultiple() { ->add(Connection::class, 'select', Select::class, 'select_1') ->add(Select::class, 'fields', Select::class) ->add(Select::class, 'condition', Select::class) - ->add(Select::class, 'execute', StatementWrapper::class) - ->add(StatementWrapper::class, 'fetch', NULL); + ->add(Select::class, 'execute', StatementInterface::class) + ->add(StatementInterface::class, 'fetch', NULL); $databaseTable = new DatabaseTable( $connectionChain->getMock(), @@ -203,8 +203,8 @@ public function testStoreMultipleFieldCountException() { ->add(Connection::class, 'select', Select::class, 'select_1') ->add(Select::class, 'fields', Select::class) ->add(Select::class, 'condition', Select::class) - ->add(Select::class, 'execute', StatementWrapper::class) - ->add(StatementWrapper::class, 'fetch', NULL); + ->add(Select::class, 'execute', StatementInterface::class) + ->add(StatementInterface::class, 'fetch', NULL); $databaseTable = new DatabaseTable( $connectionChain->getMock(), @@ -228,8 +228,8 @@ public function testCount() { ->add(Connection::class, 'select', Select::class, 'select_1') ->add(Select::class, 'fields', Select::class) ->add(Select::class, 'countQuery', Select::class) - ->add(Select::class, 'execute', StatementWrapper::class) - ->add(StatementWrapper::class, 'fetchField', 1); + ->add(Select::class, 'execute', StatementInterface::class) + ->add(StatementInterface::class, 'fetchField', 1); $databaseTable = new DatabaseTable( $connectionChain->getMock(), @@ -247,8 +247,8 @@ public function testGetSummary() { ->add(Connection::class, 'select', Select::class, 'select_1') ->add(Select::class, 'fields', Select::class) ->add(Select::class, 'countQuery', Select::class) - ->add(Select::class, 'execute', StatementWrapper::class) - ->add(StatementWrapper::class, 'fetchField', 1); + ->add(Select::class, 'execute', StatementInterface::class) + ->add(StatementInterface::class, 'fetchField', 1); $databaseTable = new DatabaseTable( $connectionChain->getMock(), @@ -294,8 +294,8 @@ public function testPrepareDataJsonDecodeNull() { ->add(Connection::class, 'select', Select::class, 'select_1') ->add(Select::class, 'fields', Select::class) ->add(Select::class, 'condition', Select::class) - ->add(Select::class, 'execute', StatementWrapper::class) - ->add(StatementWrapper::class, 'fetch', NULL); + ->add(Select::class, 'execute', StatementInterface::class) + ->add(StatementInterface::class, 'fetch', NULL); $databaseTable = new DatabaseTable( $connectionChain->getMock(), @@ -318,8 +318,8 @@ public function testPrepareDataNonArray() { ->add(Connection::class, 'select', Select::class, 'select_1') ->add(Select::class, 'fields', Select::class) ->add(Select::class, 'condition', Select::class) - ->add(Select::class, 'execute', StatementWrapper::class) - ->add(StatementWrapper::class, 'fetch', NULL); + ->add(Select::class, 'execute', StatementInterface::class) + ->add(StatementInterface::class, 'fetch', NULL); $databaseTable = new DatabaseTable( $connectionChain->getMock(), @@ -340,8 +340,8 @@ public function testQuery() { ->add(Connection::class, 'select', Select::class, 'select_1') ->add(Select::class, 'fields', Select::class) ->add(Select::class, 'condition', Select::class) - ->add(Select::class, 'execute', StatementWrapper::class) - ->add(StatementWrapper::class, 'fetchAll', []); + ->add(Select::class, 'execute', StatementInterface::class) + ->add(StatementInterface::class, 'fetchAll', []); $databaseTable = new DatabaseTable( $connectionChain->getMock(), @@ -460,9 +460,9 @@ private function getConnectionChain() { return (new Chain($this)) // Construction. ->add(Connection::class, "schema", Schema::class) - ->add(Connection::class, 'query', StatementWrapper::class) + ->add(Connection::class, 'query', StatementInterface::class) ->add(Connection::class, 'getConnectionOptions', ['driver' => 'mysql']) - ->add(StatementWrapper::class, 'fetchAll', + ->add(StatementInterface::class, 'fetchAll', (new Sequence())->add($fieldInfo)->add($indexInfo) ) ->add(Schema::class, "tableExists", TRUE) diff --git a/modules/dkan_js_frontend/dkan_js_frontend.info.yml b/modules/dkan_js_frontend/dkan_js_frontend.info.yml index 114367db58..982eafb4c1 100644 --- a/modules/dkan_js_frontend/dkan_js_frontend.info.yml +++ b/modules/dkan_js_frontend/dkan_js_frontend.info.yml @@ -1,7 +1,7 @@ name: DKAN JS Frontend description: Provides the routing connection between Drupal and a decoupled JavaScript frontend. type: module -core_version_requirement: ^10 +core_version_requirement: ^10 || ^11 dependencies: - drupal:field package: DKAN diff --git a/modules/dkan_js_frontend/tests/src/Unit/SimpleSitemapArbitraryLinksAlterTest.php b/modules/dkan_js_frontend/tests/src/Unit/SimpleSitemapArbitraryLinksAlterTest.php index 74331248ad..c898cee335 100644 --- a/modules/dkan_js_frontend/tests/src/Unit/SimpleSitemapArbitraryLinksAlterTest.php +++ b/modules/dkan_js_frontend/tests/src/Unit/SimpleSitemapArbitraryLinksAlterTest.php @@ -56,6 +56,7 @@ public function testSitemapStaticLinks(): void { $container = (new Chain($this)) ->add(Container::class, 'get', $containerOptions) ->add(RequestStack::class, 'getCurrentRequest', (Request::create(self::BASE_URL))) + ->add(LoggerChannelFactory::class, 'get', LoggerChannelInterface::class) ->add(SimpleSitemapSettingsInterface::class, 'get', NULL) ->getMock(); \Drupal::setContainer($container); diff --git a/modules/harvest/harvest.info.yml b/modules/harvest/harvest.info.yml index 78e263d581..47a743462e 100644 --- a/modules/harvest/harvest.info.yml +++ b/modules/harvest/harvest.info.yml @@ -1,7 +1,7 @@ name: Harvest description: Provides integration with the harvest library. type: module -core_version_requirement: ^10 +core_version_requirement: ^10 || ^11 package: DKAN dependencies: - dkan:common diff --git a/modules/harvest/tests/src/Unit/Storage/HarvestHashesEntityDatabaseTableTest.php b/modules/harvest/tests/src/Unit/Storage/HarvestHashesEntityDatabaseTableTest.php index 412a78bfd8..fde4a3e38b 100644 --- a/modules/harvest/tests/src/Unit/Storage/HarvestHashesEntityDatabaseTableTest.php +++ b/modules/harvest/tests/src/Unit/Storage/HarvestHashesEntityDatabaseTableTest.php @@ -16,10 +16,10 @@ */ class HarvestHashesEntityDatabaseTableTest extends TestCase { - public function providerNotImplementedMethods() { + public static function providerNotImplementedMethods() { return [ ['storeMultiple', [[]]], - ['query', [$this->createStub(Query::class)]], + ['query', [new Query()]], ['setSchema', [[]]], ['getSchema', []], ]; @@ -33,7 +33,8 @@ public function providerNotImplementedMethods() { public function testNotImplementedMethods($method, $arguments) { $table = $this->getMockBuilder(HarvestHashesEntityDatabaseTable::class) ->disableOriginalConstructor() - ->getMockForAbstractClass(); + ->onlyMethods([]) + ->getMock(); $this->expectException(\RuntimeException::class); $this->expectExceptionMessage(HarvestHashesEntityDatabaseTable::class . '::' . $method . ' not yet implemented.'); diff --git a/modules/json_form_widget/json_form_widget.info.yml b/modules/json_form_widget/json_form_widget.info.yml index c4e2e83e05..94b42a42e5 100644 --- a/modules/json_form_widget/json_form_widget.info.yml +++ b/modules/json_form_widget/json_form_widget.info.yml @@ -2,7 +2,7 @@ name: JSON Form Widget description: Provides a widget for generating a form based on JSON Schema. package: DKAN type: module -core_version_requirement: ^10 +core_version_requirement: ^10 || ^11 dependencies: - select_or_other - select2 diff --git a/modules/json_form_widget/src/WidgetRouter.php b/modules/json_form_widget/src/WidgetRouter.php index 79047a42d1..a1e1918aac 100644 --- a/modules/json_form_widget/src/WidgetRouter.php +++ b/modules/json_form_widget/src/WidgetRouter.php @@ -301,7 +301,7 @@ public function handleUploadOrLinkElement(mixed $spec, array $element) { unset($element['#default_value']); } if (isset($spec->extensions)) { - $element['#upload_validators']['file_validate_extensions'][] = $spec->extensions; + $element['#upload_validators']['FileExtension'] = ['extensions' => $spec->extensions]; } // If a maxlength was set earlier, remove it as it is not allowed here. unset($element['#maxlength']); diff --git a/modules/json_form_widget/tests/src/Unit/SchemaUiHandlerTest.php b/modules/json_form_widget/tests/src/Unit/SchemaUiHandlerTest.php index bb3a09b3a6..ca217469b9 100644 --- a/modules/json_form_widget/tests/src/Unit/SchemaUiHandlerTest.php +++ b/modules/json_form_widget/tests/src/Unit/SchemaUiHandlerTest.php @@ -523,7 +523,7 @@ public function testSchemaUi() { '#uri' => 'https://url.to.api.or.file', '#upload_location' => 'public://uploaded_resources', '#upload_validators' => [ - 'file_validate_extensions' => ['jpg pdf png csv'], + 'FileExtension' => ['extensions' => 'jpg pdf png csv'], ], ], ]; diff --git a/modules/metastore/metastore.info.yml b/modules/metastore/metastore.info.yml index ea7d02d536..ac8e103ec2 100644 --- a/modules/metastore/metastore.info.yml +++ b/modules/metastore/metastore.info.yml @@ -1,7 +1,7 @@ name: Metastore description: Provides integration with the metastore library and creates the "Data" content type for storing metadata. type: module -core_version_requirement: ^10 +core_version_requirement: ^10 || ^11 package: DKAN dependencies: - dkan:common diff --git a/modules/metastore/modules/metastore_admin/metastore_admin.info.yml b/modules/metastore/modules/metastore_admin/metastore_admin.info.yml index 5018e61060..9daefa0589 100644 --- a/modules/metastore/modules/metastore_admin/metastore_admin.info.yml +++ b/modules/metastore/modules/metastore_admin/metastore_admin.info.yml @@ -1,7 +1,7 @@ name: Administration description: Provides administrative views for managing dataset content. type: module -core_version_requirement: ^10 +core_version_requirement: ^10 || ^11 dependencies: - dkan:metastore - drupal:breakpoint diff --git a/modules/metastore/modules/metastore_facets/metastore_facets.info.yml b/modules/metastore/modules/metastore_facets/metastore_facets.info.yml index 4e5defc01c..cbc87ca50f 100644 --- a/modules/metastore/modules/metastore_facets/metastore_facets.info.yml +++ b/modules/metastore/modules/metastore_facets/metastore_facets.info.yml @@ -1,7 +1,7 @@ name: DKAN Metastore Facets description: Provides facet blocks for DKAN Metastore Search. type: module -core_version_requirement: ^10 +core_version_requirement: ^10 || ^11 dependencies: - dkan:metastore_search - facets:facets diff --git a/modules/metastore/modules/metastore_search/metastore_search.info.yml b/modules/metastore/modules/metastore_search/metastore_search.info.yml index 4467b37c83..89f2cfdee0 100644 --- a/modules/metastore/modules/metastore_search/metastore_search.info.yml +++ b/modules/metastore/modules/metastore_search/metastore_search.info.yml @@ -1,7 +1,7 @@ name: Search description: Provides an endpoint to perform searches against DKAN's metadata. type: module -core_version_requirement: ^10 +core_version_requirement: ^10 || ^11 dependencies: - dkan:metastore - drupal:search_api diff --git a/modules/metastore/modules/metastore_search/tests/src/Unit/SearchTest.php b/modules/metastore/modules/metastore_search/tests/src/Unit/SearchTest.php index 5955ab5e54..e4849271be 100644 --- a/modules/metastore/modules/metastore_search/tests/src/Unit/SearchTest.php +++ b/modules/metastore/modules/metastore_search/tests/src/Unit/SearchTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\metastore_search\Unit; -use Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher; use Drupal\Core\DependencyInjection\Container; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeManager; @@ -19,6 +18,7 @@ use MockChain\Chain; use MockChain\Options; use PHPUnit\Framework\TestCase; +use Symfony\Component\EventDispatcher\EventDispatcher; /** * Class SearchTest. @@ -75,7 +75,7 @@ public function testSearchParameterWithComma() { ->add('dkan.metastore.service', MetastoreService::class) ->add('entity_type.manager', EntityTypeManager::class) ->add('search_api.query_helper', QueryHelperInterface::class) - ->add('event_dispatcher', ContainerAwareEventDispatcher::class) + ->add('event_dispatcher', EventDispatcher::class) ->index(0); $container = (new Chain($this)) @@ -188,7 +188,7 @@ public static function getCommonMockChain(TestCase $case, Options $services = NU 'dkan.metastore.service' => MetastoreService::class, 'entity_type.manager' => EntityTypeManager::class, 'search_api.query_helper' => QueryHelperInterface::class, - 'event_dispatcher' => ContainerAwareEventDispatcher::class, + 'event_dispatcher' => EventDispatcher::class, ]; foreach ($myServices as $serviceName => $class) { diff --git a/modules/metastore/src/Form/DataDictionarySettingsForm.php b/modules/metastore/src/Form/DataDictionarySettingsForm.php index 1e3d2ebdc8..d61415de55 100644 --- a/modules/metastore/src/Form/DataDictionarySettingsForm.php +++ b/modules/metastore/src/Form/DataDictionarySettingsForm.php @@ -3,6 +3,7 @@ namespace Drupal\metastore\Form; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Messenger\MessengerInterface; @@ -32,15 +33,25 @@ class DataDictionarySettingsForm extends ConfigFormBase { /** * Constructs a \Drupal\Core\Form\ConfigFormBase object. * + * Arg order a little weird because TypedConfigManagerInterface was not + * required when this was first done. + * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The factory for configuration objects. * @param \Drupal\Core\Messenger\MessengerInterface $messenger * The messenger. * @param \Drupal\metastore\MetastoreService $metastore * The metastore service. + * @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config + * The typed config manager. */ - public function __construct(ConfigFactoryInterface $config_factory, MessengerInterface $messenger, MetastoreService $metastore) { - parent::__construct($config_factory); + public function __construct( + ConfigFactoryInterface $config_factory, + MessengerInterface $messenger, + MetastoreService $metastore, + TypedConfigManagerInterface $typed_config, + ) { + parent::__construct($config_factory, $typed_config); $this->messenger = $messenger; $this->metastore = $metastore; } @@ -57,7 +68,8 @@ public static function create(ContainerInterface $container) { return new static( $container->get('config.factory'), $container->get('messenger'), - $container->get('dkan.metastore.service') + $container->get('dkan.metastore.service'), + $container->get('config.typed') ); } diff --git a/modules/metastore/tests/src/Kernel/DataDictionarySettingsFormTest.php b/modules/metastore/tests/src/Kernel/DataDictionarySettingsFormTest.php index 3b84e993ea..0577abef40 100644 --- a/modules/metastore/tests/src/Kernel/DataDictionarySettingsFormTest.php +++ b/modules/metastore/tests/src/Kernel/DataDictionarySettingsFormTest.php @@ -222,7 +222,12 @@ protected function setUp(): void { $this->metastore->post('data-dictionary', $data_dict); $this->metastore->publish('data-dictionary', $dict_id); - $this->form = new DataDictionarySettingsForm($this->container->get('config.factory'), $this->container->get('messenger'), $this->container->get('dkan.metastore.service')); + $this->form = new DataDictionarySettingsForm( + $this->container->get('config.factory'), + $this->container->get('messenger'), + $this->container->get('dkan.metastore.service'), + $this->container->get('config.typed') + ); } } diff --git a/modules/metastore/tests/src/Unit/MetastoreServiceTest.php b/modules/metastore/tests/src/Unit/MetastoreServiceTest.php index 2383d73ab8..7703711315 100644 --- a/modules/metastore/tests/src/Unit/MetastoreServiceTest.php +++ b/modules/metastore/tests/src/Unit/MetastoreServiceTest.php @@ -4,7 +4,6 @@ use ColinODell\PsrTestLogger\TestLogger; use Drupal\Component\DependencyInjection\Container; -use Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher; use Drupal\common\Events\Event; use Drupal\Core\Logger\LoggerChannelInterface; use Drupal\metastore\Exception\ExistingObjectException; @@ -21,6 +20,7 @@ use MockChain\Sequence; use PHPUnit\Framework\TestCase; use RootedData\RootedJsonData; +use Symfony\Component\EventDispatcher\EventDispatcher; /** * @coversDefaultClass \Drupal\metastore\MetastoreService @@ -129,7 +129,7 @@ public function testGetAllException() { $container = self::getCommonMockChain($this, NULL, $logger) ->add(NodeData::class, 'retrieveAll', [json_encode(['foo' => 'bar'])]) ->add(ValidMetadataFactory::class, 'get', $data) - ->add(ContainerAwareEventDispatcher::class, 'dispatch', $sequence) + ->add(EventDispatcher::class, 'dispatch', $sequence) ->getMock(); \Drupal::setContainer($container); @@ -416,7 +416,7 @@ public static function getCommonMockChain(TestCase $case, Options $services = NU $options = (new Options) ->add('dkan.metastore.schema_retriever', SchemaRetriever::class) ->add('dkan.metastore.storage', DataFactory::class) - ->add('event_dispatcher', ContainerAwareEventDispatcher::class) + ->add('event_dispatcher', EventDispatcher::class) ->add('dkan.metastore.valid_metadata', ValidMetadataFactory::class) ->add('dkan.common.logger_channel', LoggerChannelInterface::class) ->index(0); diff --git a/modules/sample_content/sample_content.info.yml b/modules/sample_content/sample_content.info.yml index 3395f7e869..ae9a91f943 100644 --- a/modules/sample_content/sample_content.info.yml +++ b/modules/sample_content/sample_content.info.yml @@ -1,7 +1,7 @@ name: Sample Content description: Provides sample content for tests or standing up a demo instance. type: module -core_version_requirement: ^10 +core_version_requirement: ^10 || ^11 package: DKAN dependencies: - dkan:harvest