Skip to content

Commit

Permalink
Fixed inheritance issues (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish authored Feb 27, 2025
1 parent 5125bbf commit 6544529
Show file tree
Hide file tree
Showing 26 changed files with 309 additions and 115 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"drupal/auto_entitylabel": "^3.0@beta",
"drupal/better_exposed_filters": "^6.0",
"drupal/block_content_permissions": "^1.8",
"drupal/book": "^2.0",
"drupal/change_labels": "^1.0",
"drupal/chosen": "^5.0",
"drupal/ckeditor5_icons": "^1.1",
Expand Down Expand Up @@ -185,7 +186,7 @@
"su-sws/stanford_fields": "^8.4",
"su-sws/stanford_media": "^11.0",
"su-sws/stanford_migrate": "^8.3",
"su-sws/stanford_profile_helper": "^9.6",
"su-sws/stanford_profile_helper": "^9.8",
"su-sws/stanford_samlauth": "^1.0",
"su-sws/stanford_syndication": "^1.0@beta"
},
Expand Down
1 change: 1 addition & 0 deletions config/sync/config_split.config_split.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module:
dblog: 0
devel: 0
devel_php: 0
masquerade: 0
stage_file_proxy: 0
theme: { }
complete_list: { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ settings:
stanford_entity: stanford_entity
stanford_gallery: stanford_gallery
stanford_lists: stanford_lists
stanford_layout: stanford_layout
layout: layout
stanford_faq: stanford_faq
negate: 0
target_bundles_drag_drop:
Expand All @@ -61,7 +61,7 @@ settings:
stanford_gallery:
weight: 14
enabled: true
stanford_layout:
layout:
weight: 18
enabled: true
stanford_lists:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ settings:
stanford_entity: stanford_entity
stanford_gallery: stanford_gallery
stanford_lists: stanford_lists
stanford_layout: stanford_layout
layout: layout
stanford_faq: stanford_faq
negate: 0
target_bundles_drag_drop:
Expand All @@ -61,7 +61,7 @@ settings:
stanford_gallery:
weight: 14
enabled: true
stanford_layout:
layout:
weight: 18
enabled: true
stanford_lists:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ settings:
stanford_spacer: stanford_spacer
stanford_gallery: stanford_gallery
stanford_lists: stanford_lists
stanford_layout: stanford_layout
layout: layout
stanford_faq: stanford_faq
negate: 0
target_bundles_drag_drop:
Expand All @@ -61,7 +61,7 @@ settings:
stanford_gallery:
weight: 14
enabled: true
stanford_layout:
layout:
weight: 18
enabled: true
stanford_lists:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ settings:
stanford_card: stanford_card
stanford_entity: stanford_entity
stanford_gallery: stanford_gallery
stanford_layout: stanford_layout
layout: layout
stanford_lists: stanford_lists
stanford_media_caption: stanford_media_caption
stanford_spacer: stanford_spacer
Expand All @@ -61,7 +61,7 @@ settings:
stanford_gallery:
weight: 18
enabled: true
stanford_layout:
layout:
weight: 19
enabled: true
stanford_lists:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ settings:
stanford_media_caption: stanford_media_caption
stanford_entity: stanford_entity
stanford_gallery: stanford_gallery
stanford_layout: stanford_layout
layout: layout
stanford_lists: stanford_lists
stanford_spacer: stanford_spacer
stanford_faq: stanford_faq
Expand All @@ -61,7 +61,7 @@ settings:
stanford_gallery:
weight: -19
enabled: true
stanford_layout:
layout:
weight: -18
enabled: true
stanford_lists:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ settings:
stanford_spacer: stanford_spacer
stanford_gallery: stanford_gallery
stanford_lists: stanford_lists
stanford_layout: stanford_layout
layout: layout
stanford_faq: stanford_faq
negate: 0
target_bundles_drag_drop:
Expand All @@ -61,7 +61,7 @@ settings:
stanford_gallery:
weight: 14
enabled: true
stanford_layout:
layout:
weight: 18
enabled: true
stanford_lists:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ settings:
stanford_card: stanford_card
stanford_entity: stanford_entity
stanford_gallery: stanford_gallery
stanford_layout: stanford_layout
layout: layout
stanford_lists: stanford_lists
stanford_media_caption: stanford_media_caption
stanford_spacer: stanford_spacer
Expand All @@ -61,7 +61,7 @@ settings:
stanford_gallery:
weight: 17
enabled: true
stanford_layout:
layout:
weight: 18
enabled: true
stanford_lists:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
adding:
hidden:
book_navigation: true
caw_page_resource_category: true
caw_page_resource_role: true
caw_page_resource_type: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ adding:
- field.field.node.stanford_page.caw_page_resource_role
- field.field.node.stanford_page.caw_page_resource_type
hidden:
book_navigation: true
caw_page_resource_category: true
caw_page_resource_role: true
caw_page_resource_type: true
removing:
hidden:
book_navigation: true
removing: { }
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ adding:
- field.field.node.stanford_page.caw_page_resource_role
- field.field.node.stanford_page.caw_page_resource_type
hidden:
book_navigation: true
caw_page_resource_category: true
caw_page_resource_role: true
caw_page_resource_type: true
removing:
hidden:
book_navigation: true
removing: { }
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
adding:
hidden:
book_navigation: true
caw_page_resource_category: true
caw_page_resource_role: true
caw_page_resource_type: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SubsiteMenuBlock extends BookNavigationBlock {
/**
* {@inheritDoc}
*/
public function build() {
public function build(): array {
$build = parent::build();
$subsite_node = BookManager::getSubsiteNode(TRUE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
/**
* Provides behaviors for card paragraphs to add color classes.
*
* @codeCoverageIgnore
*
* @ParagraphsBehavior(
* id = "card_color",
* label = @Translation("Card Colors"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* Provides behaviors for card paragraphs to add color classes.
*
* @codeCoverageIgnore
*/
class CawCardBehavior extends CardBehavior {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* Provides behaviors for card paragraphs to add color classes.
*
* @codeCoverageIgnore
*/
class CawHeroBehavior extends HeroPatternBehavior {

Expand Down
2 changes: 2 additions & 0 deletions modules/caw_profile_helper/src/Routing/RouteSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

/**
* Listens to the dynamic route events.
*
* @codeCoverageIgnore
*/
class RouteSubscriber extends RouteSubscriberBase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testBookTreeData() {
'bid' => $this->subsite->id(),
];
$child_page->save();
\Drupal::service('book.memory_cache')->deleteAll();
\Drupal::service('cache.book_memory')->deleteAll();

$link = $book_manager->loadBookLink($this->subsite->id());
$tree_data = $book_manager->bookTreeAllData($this->subsite->id(), $link);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Drupal\Tests\caw_profile_helper\Kernel;

use Drupal\KernelTests\KernelTestBase;
Expand Down Expand Up @@ -43,7 +42,7 @@ public function setUp(): void {
$this->installEntitySchema('node');
$this->installEntitySchema('user');
$this->installConfig(['user']);
$this->installConfig('system');
$this->installConfig(['system', 'book']);
$this->installSchema('book', 'book');
\Drupal::configFactory()
->getEditable('system.site')
Expand All @@ -55,7 +54,11 @@ public function setUp(): void {
$anonymous_role->save();

NodeType::create(['type' => 'page'])->save();
$this->subsite = Node::create(['type' => 'page', 'title' => 'Book Name', 'status' => TRUE]);
$this->subsite = Node::create([
'type' => 'page',
'title' => 'Book Name',
'status' => TRUE,
]);
$this->subsite->book = [
'nid' => NULL,
'bid' => 'new',
Expand All @@ -66,6 +69,11 @@ public function setUp(): void {
'weight' => 0,
];
$this->subsite->save();

\Drupal::configFactory()
->getEditable('book.settings')
->set('allowed_types', ['page'])
->save();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Drupal\Tests\caw_profile_helper\Kernel\Config;

use Drupal\book\Access\BookNodeOutlineAccessCheck;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\node\NodeInterface;
use Drupal\Tests\caw_profile_helper\Kernel\CawProfileHelperKernelTestBase;
Expand All @@ -14,36 +16,52 @@
*/
class BookConfigOverridderTest extends CawProfileHelperKernelTestBase {

/**
* {@inheritDoc}
*/
public function setUp(): void {
parent::setUp();

$access_result = $this->createMock(AccessResult::class);
$access_result->method('isAllowed')->willReturn(TRUE);

$outline_access_check = $this->createMock(BookNodeOutlineAccessCheck::class);
$outline_access_check->method('access')->willReturn($access_result);
\Drupal::getContainer()
->set('access_check.book.node_outline', $outline_access_check);
}

/**
* Just a basic config test without any node influence.
*/
public function testSitename(){
public function testSitename() {
$this->assertEquals('Foo Bar', \Drupal::config('system.site')
->get('name'));
}

/**
* On an node page but not in a subsite, the sitename doesn't change.
* On a node page but not in a subsite, the sitename doesn't change.
*/
public function testSitenameOutsideSubsite(){
public function testSitenameOutsideSubsite() {

$node = $this->createMock(NodeInterface::class);
$node->book = ['bid' => 99999];
$route_match = $this->createMock(RouteMatchInterface::class);
$route_match->method('getParameter')->willReturn($node);
\Drupal::getContainer()->set('current_route_match',$route_match);
\Drupal::getContainer()->set('current_route_match', $route_match);
$this->assertEquals('Foo Bar', \Drupal::config('system.site')
->get('name'));
}

/**
* On an node page in a subsite, the sitename changes.
*/
public function testSiteNameWithinSubsite(){
public function testSiteNameWithinSubsite() {
$node = $this->createMock(NodeInterface::class);
$node->book = ['bid' => $this->subsite->id()];
$route_match = $this->createMock(RouteMatchInterface::class);
$route_match->method('getParameter')->willReturn($node);
\Drupal::getContainer()->set('current_route_match',$route_match);
\Drupal::getContainer()->set('current_route_match', $route_match);
$this->assertEquals($this->subsite->label(), \Drupal::config('system.site')
->get('name'));
}
Expand Down
10 changes: 5 additions & 5 deletions tests/codeception/functional/Paragraphs/FAQCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testFaq(FunctionalTester $I) {

$I->canSee($node->label(), 'h1');
$I->canSee('FAQ Headliner', 'h2');
$I->canSee('the knock-knock joke', 'details');
$I->canSee('the knock-knock joke', 'button');
$I->canSee('Expand All', 'button');
$I->cantSeeElement('details[open]');

Expand All @@ -74,7 +74,7 @@ public function testFaq(FunctionalTester $I) {
$I->canSee('“no-bell” prize');
$I->canSee('An impasta');
$I->canSee('Collapse All', 'button');
$I->canSeeElement('details[open]');
$I->canSeeElement('button[aria-expanded=true]');
}


Expand Down Expand Up @@ -123,18 +123,18 @@ public function testFaqNews(FunctionalTester $I) {

$I->canSee($node->label(), 'h1');
$I->canSee('FAQ Headliner', 'h2');
$I->canSee('the knock-knock joke', 'details');
$I->canSee('the knock-knock joke', 'button');
$I->waitForElementVisible('.expand-collapse-button');

$I->canSee('Expand All', 'button');
$I->cantSeeElement('details[open]');
$I->cantSeeElement('button[aria-expanded=true]');

$I->canSeeNumberOfElements('.expand-collapse-button', 1);
$I->click('Expand All');
$I->canSee('“no-bell” prize');
$I->canSee('An impasta');
$I->canSee('Collapse All', 'button');
$I->canSeeElement('details[open]');
$I->canSeeElement('button[aria-expanded=true]');
}

}
Loading

0 comments on commit 6544529

Please sign in to comment.