Update and export slides
This commit is contained in:
parent
242410f8c0
commit
fa9e60e6cd
4 changed files with 159 additions and 24 deletions
BIN
tdd-test-driven-drupal/2019-03-02-drupalcamp-london/slides.pdf
Normal file
BIN
tdd-test-driven-drupal/2019-03-02-drupalcamp-london/slides.pdf
Normal file
Binary file not shown.
|
@ -53,7 +53,7 @@ code: Monaco, #6699FF, #999999, #6666FF, #66FF66, #66FF66, line-height(1.3)
|
|||
- Part-time freelancer
|
||||
- Acquia certified Drupal 8 Grand Master
|
||||
- Drupal 7 & 8 core contributor
|
||||
- Symfony, Laravel, ~~Silex,~~ Sculpin
|
||||
- Drupal, Symfony, Laravel, Sculpin
|
||||
- @opdavies
|
||||
- www.oliverdavies.uk
|
||||
|
||||
|
@ -91,6 +91,13 @@ Blog on my website
|
|||
|
||||
## test_driven_drupal_.com_
|
||||
|
||||
^ Book on automated testing in Drupal 8
|
||||
Building a conference website
|
||||
|
||||
---
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
[.header: alignment(center)]
|
||||
|
@ -124,9 +131,9 @@ Blog on my website
|
|||
- Used on _11,046 sites_ in October 2012 (_84_ D5, _7,094_ D6, _3,868_ D7)
|
||||
- Used on _30,572 sites_ in March 2019 (_10_ D5, _1,180_ D6, _24,057_ D7, _5,335_ D8)
|
||||
- _#230_ most used module on Drupal.org
|
||||
- Crucial to preventing regressions when adding new features or fixing bugs
|
||||
- Crucial to preventing regressions
|
||||
|
||||
^ Preventing regressions in my additions but also user submitted patches
|
||||
^ Preventing regressions when adding new features or fixing bugs, but also user submitted patches
|
||||
First module I ported to Drupal 8, aided by tests
|
||||
|
||||
---
|
||||
|
@ -159,7 +166,13 @@ ONO merge conflict
|
|||
- If the feature does not have an implementation, provide a test implementation.
|
||||
- Bug fixes should be accompanied by changes to a test (either modifying an existing test case or adding a new one) that demonstrate the bug.
|
||||
|
||||
[.footer: https://www.drupal.org/core/gates#testing]
|
||||
[.footer: https://opdavi.es/drupal-core-testing-gate]
|
||||
|
||||
---
|
||||
|
||||
[.background-color: #FFFFFF]
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
|
@ -171,6 +184,10 @@ ONO merge conflict
|
|||
|
||||
---
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
[.header: #53B0EB]
|
||||
|
||||
## Writing Tests (Drupal 8)
|
||||
|
@ -181,7 +198,6 @@ ONO merge conflict
|
|||
- Class name must match the filename
|
||||
- Namespace must match the directory structure
|
||||
- One test class per feature
|
||||
- Each method must start with _test_
|
||||
|
||||
^ Different to D7
|
||||
|
||||
|
@ -195,6 +211,13 @@ ONO merge conflict
|
|||
|
||||
---
|
||||
|
||||
[.header: alignment(center)]
|
||||
|
||||
## _3._ Assert
|
||||
## _2._ Act
|
||||
## _1._ Arrange
|
||||
|
||||
---
|
||||
|
||||
```php
|
||||
// modules/example/tests/src/Functional/ExampleTest.php
|
||||
|
@ -224,6 +247,17 @@ Add test method
|
|||
|
||||
---
|
||||
|
||||
```php
|
||||
public function testSomething() {}
|
||||
|
||||
public function test_something() {}
|
||||
|
||||
/** @test */
|
||||
public function it_does_something() {}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
[.header: #53B0EB]
|
||||
|
||||
## What to test?
|
||||
|
@ -321,8 +355,6 @@ class JobTest extends UnitTestCase {
|
|||
^ Within a Unit directory and namespace
|
||||
Called JobTest because it's testing the Job class
|
||||
Called testCreate because it's testing the create method
|
||||
Create a job with the create method
|
||||
Retrieve data from the object with getters
|
||||
|
||||
---
|
||||
|
||||
|
@ -347,6 +379,8 @@ class JobTest extends UnitTestCase {
|
|||
}
|
||||
```
|
||||
|
||||
^ Create a job with the create method
|
||||
|
||||
---
|
||||
|
||||
```php, [.highlight: 13-15]
|
||||
|
@ -370,6 +404,9 @@ class JobTest extends UnitTestCase {
|
|||
}
|
||||
```
|
||||
|
||||
^ Retrieve data from the object with getters
|
||||
Asssert that the data is correct.
|
||||
|
||||
---
|
||||
|
||||
[.header: #53B0EB]
|
||||
|
@ -424,6 +461,8 @@ protected function setUp() {
|
|||
}
|
||||
```
|
||||
|
||||
^ Steps that need to run before each test method
|
||||
|
||||
---
|
||||
|
||||
```php, [.highlight: 6]
|
||||
|
@ -448,6 +487,8 @@ protected function setUp() {
|
|||
}
|
||||
```
|
||||
|
||||
^ Create the database tables
|
||||
|
||||
---
|
||||
|
||||
```php, [.highlight: 8-16]
|
||||
|
@ -472,6 +513,8 @@ protected function setUp() {
|
|||
}
|
||||
```
|
||||
|
||||
^ Create and save a queue
|
||||
|
||||
---
|
||||
|
||||
```php, [.highlight: 18]
|
||||
|
@ -496,6 +539,9 @@ protected function setUp() {
|
|||
}
|
||||
```
|
||||
|
||||
^ Because it's a kernel test, we have access to the container
|
||||
to get the AdvancedQueue processor service.
|
||||
|
||||
---
|
||||
|
||||
```php
|
||||
|
@ -524,6 +570,8 @@ public function testProcessor() {
|
|||
}
|
||||
```
|
||||
|
||||
^ Start by creating some jobs.
|
||||
|
||||
---
|
||||
|
||||
```php, [.highlight: 6-10]
|
||||
|
@ -543,6 +591,8 @@ public function testProcessor() {
|
|||
}
|
||||
```
|
||||
|
||||
^ Add the jobs to the queue
|
||||
|
||||
---
|
||||
|
||||
```php, [.highlight: 11-13]
|
||||
|
@ -562,6 +612,8 @@ public function testProcessor() {
|
|||
}
|
||||
```
|
||||
|
||||
^ Process the queue, and check the number of processed items.
|
||||
|
||||
---
|
||||
|
||||
[.header: #53B0EB]
|
||||
|
@ -576,6 +628,8 @@ public function testProcessor() {
|
|||
- With/without JavaScript
|
||||
|
||||
^ testing profile
|
||||
Functional/FunctionalJavascript
|
||||
Nightwatch
|
||||
|
||||
---
|
||||
|
||||
|
@ -593,6 +647,8 @@ class QueueTest extends BrowserTestBase {
|
|||
}
|
||||
```
|
||||
|
||||
^ Extend BrowserTestBase
|
||||
|
||||
---
|
||||
|
||||
```php, [.highlight: 6-8]
|
||||
|
@ -610,6 +666,9 @@ protected function setUp() {
|
|||
}
|
||||
```
|
||||
|
||||
^ We have the ability to place blocks
|
||||
And create users with permissions and log them in
|
||||
|
||||
---
|
||||
|
||||
```php, [.highlight: 10-11]
|
||||
|
@ -651,7 +710,6 @@ public function testQueueDeletion() {
|
|||
```
|
||||
|
||||
---
|
||||
|
||||
```php, [.highlight: 12-14]
|
||||
// tests/src/Functional/QueueTest.php
|
||||
|
||||
|
@ -673,6 +731,8 @@ public function testQueueDeletion() {
|
|||
}
|
||||
```
|
||||
|
||||
^ I prefer to use the route name and Url::fromRoute
|
||||
|
||||
---
|
||||
|
||||
```php, [.highlight: 16-17]
|
||||
|
@ -1003,18 +1063,17 @@ $ php core/scripts/run-tests.sh --class ExampleTest
|
|||
---
|
||||
|
||||
```
|
||||
cd web
|
||||
|
||||
../vendor/bin/phpunit -c core \
|
||||
vendor/bin/phpunit \
|
||||
-c core \
|
||||
modules/contrib/examples/phpunit_example
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```
|
||||
cd web/core
|
||||
cd core
|
||||
|
||||
../../vendor/bin/phpunit \
|
||||
../vendor/bin/phpunit \
|
||||
../modules/contrib/examples/phpunit_example
|
||||
```
|
||||
|
||||
|
@ -1036,8 +1095,23 @@ cd web/core
|
|||
|
||||
---
|
||||
|
||||
# _Docksal_
|
||||
|
||||
```
|
||||
fin addon install phpunit
|
||||
|
||||
fin phpunit modules/custom
|
||||
```
|
||||
|
||||
^ Copies a stub phpunit.xml file or copies phpunit.xml.dist
|
||||
Runs the phpunit command within the correct directory
|
||||
|
||||
---
|
||||
|
||||

|
||||
|
||||
[.footer: opdavi.es/docksal-phpunit-phpstorm]
|
||||
|
||||
---
|
||||
|
||||
[.header: alignment(center)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue