Add example module with a deprecation

This commit is contained in:
Oliver Davies 2020-08-28 18:55:52 +01:00
parent e414469ca0
commit c3b71960f5
3 changed files with 48 additions and 0 deletions

View file

@ -0,0 +1,7 @@
name: Example module
description: An example module.
type: module
core_version_requirement: ^8 || ^9
dependencies:
- drupal:filter
- drupal:node

View file

@ -0,0 +1,17 @@
<?php
/**
* @file
* An example module.
*/
declare(strict_types=1);
use Drupal\Core\Entity\EntityInterface;
/**
* Implements hook_entity_view().
*/
function example_entity_view(array &$build, EntityInterface $entity): void {
drupal_set_message(t('This is a node.'));
}

View file

@ -0,0 +1,24 @@
<?php
namespace Drupal\Tests\example\Functional;
use Drupal\Tests\BrowserTestBase;
class DisplayMessageTest extends BrowserTestBase {
protected $defaultTheme = 'stable';
protected static $modules = ['filter', 'node', 'example'];
/** @test */
public function a_message_is_displayed_on_nodes(): void {
$this->drupalCreateContentType(['type' => 'page']);
$this->drupalCreateNode();
$this->drupalGet('node/1');
$this->assertText('This is a node.');
}
}