Re-add syntax highlighting to daily emails and

...ATDC lessons
This commit is contained in:
Oliver Davies 2024-02-18 01:35:59 +00:00
parent 0d9bb37503
commit 5fbf48d9ac
48 changed files with 186 additions and 165 deletions

View file

@ -22,7 +22,7 @@ For example, how do we test the administration pages to see if they work for a u
Let's start with a new test:
```php
```language-php
public function testAdminPageLoggedIn(): void {
$this->drupalGet('/admin');
@ -47,7 +47,7 @@ This is commonly known as the **Arrange** step of the test.
To create a user, use `$this->drupalCreateUser()` and `$this->drupalLogin()` to log in as that user.
```php
```language-php
$user = $this->drupalCreateUser();
$this->drupalLogin($user);
@ -61,7 +61,7 @@ As we're testing against a temporary Drupal installation, we don't have access t
To do this, when creating the user, include an array of permissions to add to it:
```php
```language-php
$user = $this->createUser(permissions: [
'access administration pages',
'administer site configuration',
@ -80,7 +80,7 @@ Let's create a page and test we can view it.
Firstly, let's ensure the page is not found:
```php
```language-php
public function testContent(): void {
$this->drupalGet('/node/1');
$this->assertSession()->statusCodeEquals(Response::HTTP_NOT_FOUND);
@ -91,7 +91,7 @@ Similar to `$this->createUser()`, there are similar methods to create content ty
Again, as there are no existing content or content types, we need to create them and add the follow-up assertions:
```php
```language-php
public function testContent(): void {
// ...
@ -111,7 +111,7 @@ You're probably expecting the test to pass now, but you'll likely get an error l
To fix this, we need to tell Drupal to enable the `node` module within the test by adding this within the test class:
```php
```language-php
protected static $modules = ['node'];
```
@ -123,7 +123,7 @@ Here's a tip for today: if you're getting an unexpected status code or another e
To do that, add this to your test, and it will output the page content:
```php
```language-php
var_dump($this->getSession()->getPage()->getContent());
```