Update slides
This commit is contained in:
parent
d39f10203f
commit
97d1f11263
1 changed files with 43 additions and 13 deletions
|
@ -8,6 +8,8 @@ theme: next, 9
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
[.build-lists: false]
|
||||||
|
|
||||||
- PHP code
|
- PHP code
|
||||||
- Mixture of D7 and D8
|
- Mixture of D7 and D8
|
||||||
- SimpleTest (D7)
|
- SimpleTest (D7)
|
||||||
|
@ -24,7 +26,12 @@ theme: next, 9
|
||||||
- @opdavies
|
- @opdavies
|
||||||
- oliverdavies.uk
|
- oliverdavies.uk
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## I write and release contrib modules for the community.<br><br>
|
||||||
|
## I write custom modules for client projects.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -54,15 +61,6 @@ ONO merge conflict
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Why Not Test?
|
|
||||||
|
|
||||||
- Don't know how
|
|
||||||
- No time/budget to write tests
|
|
||||||
|
|
||||||
^ "I'd love to write tests, but I don't have the time to learn."
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Core Testing Gate
|
## Core Testing Gate
|
||||||
|
|
||||||
New features should be accompanied by automated tests.
|
New features should be accompanied by automated tests.
|
||||||
|
@ -338,6 +336,15 @@ $this->drupalLogout();
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Assertions
|
||||||
|
|
||||||
|
- `assertText`
|
||||||
|
`assertSession()->pageTextContains()`
|
||||||
|
- `assertNoText`
|
||||||
|
`assertSession()->pageTextNotContains()`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## [fit] Running Tests
|
## [fit] Running Tests
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -904,13 +911,29 @@ public function testOnlyPublishedPagesAreShown() {
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
```php
|
||||||
|
public function testOnlyPublishedPagesAreShown() {
|
||||||
|
...
|
||||||
|
|
||||||
|
$this->drupalGet('pages');
|
||||||
|
|
||||||
|
$this->assertSession()
|
||||||
|
->pageTextContains($nodeA->label());
|
||||||
|
|
||||||
|
$this->assertSession()
|
||||||
|
->pageTextNotContains($nodeB->label());
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
```php
|
```php
|
||||||
public function testOnlyPublishedPagesAreShown() {
|
public function testOnlyPublishedPagesAreShown() {
|
||||||
...
|
...
|
||||||
|
|
||||||
$results = views_get_view_result('pages');
|
$results = views_get_view_result('pages');
|
||||||
|
|
||||||
$nids = collect($results)->pluck('nid')->all();
|
$nids = array_column($results, 'nid');
|
||||||
// [1, 3]
|
// [1, 3]
|
||||||
|
|
||||||
// I should only see the published pages.
|
// I should only see the published pages.
|
||||||
|
@ -925,7 +948,7 @@ public function testOnlyPublishedPagesAreShown() {
|
||||||
|
|
||||||
$results = views_get_view_result('pages');
|
$results = views_get_view_result('pages');
|
||||||
|
|
||||||
$nids = collect($results)->pluck('nid')->all();
|
$nids = array_column($results, 'nid');
|
||||||
// [1, 3]
|
// [1, 3]
|
||||||
|
|
||||||
$this->assertEquals([1], $nids);
|
$this->assertEquals([1], $nids);
|
||||||
|
@ -1014,7 +1037,7 @@ public function testPagesAreOrderedAlphabetically() {
|
||||||
|
|
||||||
$results = views_get_view_result('pages');
|
$results = views_get_view_result('pages');
|
||||||
|
|
||||||
$nids = collect($results)->pluck('nid')->all();
|
$nids = array_column($results, 'nid');
|
||||||
|
|
||||||
$this->assertEquals([1, 3, 4, 2], $nids);
|
$this->assertEquals([1, 3, 4, 2], $nids);
|
||||||
}
|
}
|
||||||
|
@ -1114,6 +1137,13 @@ Manual testing is still important
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Resources
|
||||||
|
|
||||||
|
- https://github.com/opdavies/tdd_dublin
|
||||||
|
- https://oliverdavies.uk/blog/tdd-test-driven-drupal
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Thanks!
|
## Thanks!
|
||||||
# Questions?
|
# Questions?
|
||||||
### @opdavies
|
### @opdavies
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue