44
55namespace Drupal \Tests \psulib_base_helper \Unit \Hook ;
66
7- use Drupal \Core \Config \ConfigFactoryInterface ;
8- use Drupal \Core \Config \ImmutableConfig ;
7+ use Drupal \Core \Extension \ThemeSettingsProvider ;
98use Drupal \psulib_base_helper \Hook \ThemeHooks ;
109use Drupal \psulib_base_helper \PsuFederatedDataFetcher ;
1110use Drupal \Tests \UnitTestCase ;
@@ -29,18 +28,11 @@ class ThemeHooksTest extends UnitTestCase {
2928 protected $ dataFetcher ;
3029
3130 /**
32- * The mocked config factory .
31+ * The mocked theme settings provider .
3332 *
34- * @var \Drupal\Core\Config\ConfigFactoryInterface |\PHPUnit\Framework\MockObject\MockObject
33+ * @var \Drupal\Core\Extension\ThemeSettingsProvider |\PHPUnit\Framework\MockObject\MockObject
3534 */
36- protected $ configFactory ;
37-
38- /**
39- * The mocked config.
40- *
41- * @var \Drupal\Core\Config\ImmutableConfig|\PHPUnit\Framework\MockObject\MockObject
42- */
43- protected $ config ;
35+ protected $ themeSettingsProvider ;
4436
4537 /**
4638 * The ThemeHooks instance.
@@ -56,16 +48,11 @@ protected function setUp(): void {
5648 parent ::setUp ();
5749
5850 $ this ->dataFetcher = $ this ->createMock (PsuFederatedDataFetcher::class);
59- $ this ->configFactory = $ this ->createMock (ConfigFactoryInterface::class);
60- $ this ->config = $ this ->createMock (ImmutableConfig::class);
61-
62- $ this ->configFactory ->method ('get ' )
63- ->with ('psulib_base.settings ' )
64- ->willReturn ($ this ->config );
51+ $ this ->themeSettingsProvider = $ this ->createMock (ThemeSettingsProvider::class);
6552
6653 $ this ->hooks = new ThemeHooks (
6754 $ this ->dataFetcher ,
68- $ this ->configFactory
55+ $ this ->themeSettingsProvider
6956 );
7057 }
7158
@@ -74,7 +61,7 @@ protected function setUp(): void {
7461 */
7562 #[Test]
7663 public function testFederatedFooterAddedWhenSettingsAndDataPresent (): void {
77- $ this ->config ->method ('get ' )
64+ $ this ->themeSettingsProvider ->method ('getSetting ' )
7865 ->with ('show_federated_footer ' )
7966 ->willReturn (TRUE );
8067
@@ -118,7 +105,7 @@ public function testFederatedFooterAddedWhenSettingsAndDataPresent(): void {
118105 #[Test]
119106 #[DataProvider('federatedFooterNotAddedProvider ' )]
120107 public function testFederatedFooterNotAddedWhenNoDataOrDisabled (?bool $ showSetting , array $ data , bool $ expectFetcherCall ): void {
121- $ this ->config ->method ('get ' )
108+ $ this ->themeSettingsProvider ->method ('getSetting ' )
122109 ->with ('show_federated_footer ' )
123110 ->willReturn ($ showSetting );
124111
0 commit comments