Skip to content
Snippets Groups Projects
Commit 60c1e0fc authored by Josha Hubbers's avatar Josha Hubbers Committed by Josha Hubbers
Browse files

Issue #3354277 by JoshaHubbers: PHPcs issues

parent d84199d7
No related branches found
No related tags found
No related merge requests found
......@@ -39,4 +39,3 @@ delete it ;-).
Current maintainers:
- Josha Hubbers (JoshaHubbers) - https://www.drupal.org/u/joshahubbers-0
......@@ -51,9 +51,12 @@ function prevent_homepage_deletion_node_access(EntityInterface $entity, $operati
* Helper function that checks if the current user can delete this node.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* Current entity.
* @param \Drupal\Core\Session\AccountInterface $account
* User account.
*
* @return bool
* True if the page can be deleted by this user.
*/
function _prevent_homepage_deletion_check(EntityInterface $entity, AccountInterface $account) {
$candelete = TRUE;
......
......@@ -8,7 +8,6 @@ use Drupal\Tests\BrowserTestBase;
* Tests the functionality of this module.
*
* @group prevent_homepage_deletion
*
*/
class DeleteHomepageTest extends BrowserTestBase {
......@@ -30,11 +29,18 @@ class DeleteHomepageTest extends BrowserTestBase {
protected $contentType;
/**
* Our two nodes.
* Homepage node.
*
* @var \Drupal\node\NodeInterface
*/
protected $pageHome;
/**
* Node that is not the homepage.
*
* @var \Drupal\node\NodeInterface
*/
protected $page_home;
protected $page_not_home;
protected $pageNotHome;
/**
* {@inheritdoc}
......@@ -44,14 +50,14 @@ class DeleteHomepageTest extends BrowserTestBase {
// Add a content type.
$this->contentType = $this->createContentType(['type' => 'page']);
// Create a first page (homepage).
$this->page_home = $this->drupalCreateNode(['type' => 'page']);
$this->pageHome = $this->drupalCreateNode(['type' => 'page']);
// Set page to be homepage.
\Drupal::configFactory()
->getEditable('system.site')
->set('page.front', '/node/'.$this->page_home->id())
->set('page.front', '/node/' . $this->pageHome->id())
->save(TRUE);
// Create a second page (not homepage).
$this->page_not_home = $this->drupalCreateNode(['type' => 'page']);
$this->pageNotHome = $this->drupalCreateNode(['type' => 'page']);
}
/**
......@@ -67,7 +73,7 @@ class DeleteHomepageTest extends BrowserTestBase {
);
// Step 2: Try to delete the homepage.
$this->drupalGet('node/' . $this->page_home->id() . '/delete');
$this->drupalGet('node/' . $this->pageHome->id() . '/delete');
$this->assertSession()->statusCodeEquals(200);
// Step 3: Logout, and login as user without the permission.
......@@ -79,11 +85,11 @@ class DeleteHomepageTest extends BrowserTestBase {
);
// Step 4: Try to delete the homepage.
$this->drupalGet('node/' . $this->page_home->id() . '/delete');
$this->drupalGet('node/' . $this->pageHome->id() . '/delete');
$this->assertSession()->statusCodeEquals(403);
// Step 5: Try to delete the non-homepage.
$this->drupalGet('node/' . $this->page_not_home->id() . '/delete');
$this->drupalGet('node/' . $this->pageNotHome->id() . '/delete');
$this->assertSession()->statusCodeEquals(200);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment