Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Testen mit TYPO3 für Fortgeschrittene
Search
Oliver Klee
May 30, 2018
Technology
220
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Testen mit TYPO3 für Fortgeschrittene
Oliver Klee
May 30, 2018
More Decks by Oliver Klee
See All by Oliver Klee
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
120
Team-Management-Plattform
oliverklee
0
88
Vertrauen in Teams & Führung
oliverklee
0
320
Software-Qualität von TYPO3-Extensions automatisieren
oliverklee
0
59
Vertrauen in Teams & Führung
oliverklee
0
180
Testing von TYPO3-Extensions
oliverklee
0
100
Software-Qualität von Extensions automatisieren
oliverklee
1
63
Content-Synchronisierung
oliverklee
0
190
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
390
Other Decks in Technology
See All in Technology
Webの技術とガジェットで子どもも大人も楽しめるワクワク体験を提供する / Qiita Tech Festa Day 2026
you
PRO
1
230
副作用のある Lambda でも Lambda Power Tuning は使えるのか / lambda-power-tuning-side-effects
koukihosaka
2
150
VPCセキュリティ対応の最新事情
nagisa53
1
300
「顧客の声を聞かなければ何も始まらない」 ── 顧客の声から生まれた『AI返信補助機能』の開発プロセス / AICon2026_shikata_imai
rakus_dev
1
270
Vポイント分析基盤におけるデータモデリング20年史
taromatsui_cccmkhd
4
750
人とエージェントが高め合う協業設計
kintotechdev
0
800
複数プロダクト組織のAIネイティブ化における戦略 / AICon2026_kude
rakus_dev
0
300
AIコード生成×サプライチェーン攻撃 — PHPが直面する“二重の信頼問題
shinyasaita
0
470
Type-safe IaC for Dart
coborinai
0
180
AI時代のPlaywright活用(システムテストを自動化する ー 実行エンジンにPla ywrightを選んだ理由)
ynisqa1988
2
980
事業成長とAI活用を止めないデータ基盤アーキテクチャの設計思想
hiracky16
0
630
ダッシュボード"開発"について 〜使われるダッシュボードのつくりかた〜
kimichan
0
210
Featured
See All Featured
Being A Developer After 40
akosma
91
590k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
190
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
240
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
410
Designing for humans not robots
tammielis
254
26k
Automating Front-end Workflow
addyosmani
1370
210k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Product Roadmaps are Hard
iamctodd
55
12k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.3k
Transcript
Testen mit TYPO3 (advanced) Oliver Klee, 2018-05 @oliklee |
[email protected]
Cartoon: www.fuchskind.de
Test-Level http://filipdefar.com/2015/06/tested-be-thy-name.html
Unit-Tests sind klein und schnell
Integrationstests testen das Zusammenspiel von Komponenten in TYPO3: „Functional Tests“
Systemtests testen das große Ganze
Test-Typen
Blackbox-Tests testen das nach außen Sichtbare
Whitebox-Tests wie genau es innen funktioniert testen,
Functional Tests
Akzeptanztests
Anti- Zombie- Tests-
Regressionstests
Smoketests
Smoketests
Story-Tests für Behavior-Driven Development (BDD)
None
Was bisher geschah
None
Deprecated seit PHPUnit 5.4.0 $this->backEndUser = $this->getMock( BackendUserAuthentication::class ); Empfohlen
seit PHPUnit 5.4.0 $this->backEndUser = $this->createMock( BackendUserAuthentication::class ); Änderungen bei Mocks $this->backEndUser = $this->getMockBuilder( BackendUserAuthentication::class )->disableOriginalConstructor() ->disableOriginalClone();
Prophecy: Empfohlen für Stubs (vollständige Mocks) Änderungen bei Mocks $this->viewProphecy
= $this->prophesize(TemplateView::class); $this->view = $this->viewProphecy->reveal(); … $this->viewProphecy->assign('tea', $tea)->shouldBeCalled(); PHPUnit-Mocks: Weiterhin empfohlen für partielle Mocks $this->controller = $this->getMockBuilder(TeaController::class) ->setMethods(['forward', 'redirect']);
Testing-Frameworks Testing-Framework der PHPUnit-Extension typo3/testing-framework nimut/testing-framework
Testing-Frameworks Testing-Framework der PHPUnit-Extension typo3/testing-framework nimut/testing-framework erhält keine neuen Features
mehr kompatibel bis TYPO3 CMS 8.7 benutzt eine echte TYPO3-Instanz
Testing-Frameworks Testing-Framework der PHPUnit-Extension typo3/testing-framework nimut/testing-framework läuft auf Linux und
Mac, nicht unter Windows API variiert zwischen TYPO3-Versionen wird vom Core-Team gepflegt
Testing-Frameworks Testing-Framework der PHPUnit-Extension typo3/testing-framework nimut/testing-framework läuft auf Linux, Mac
und Windows API ist identisch zwischen TYPO3-Versionen wird von Nicole und Helmut gepflegt
Testing-Frameworks Testing-Framework der PHPUnit-Extension typo3/testing-framework nimut/testing-framework nicht für neue Projekte
benutzen für Projekte unter genau einer TYPO3-Version für Extensions über mehrere TYPO3-Versionen
PhantomJS ist tot stattdessen empfohlen: Chromedriver Änderungen bei Akzeptanztests PHPUnit-Selenium
wird nicht mehr brauchbar gewartet hat keine aktuelle Dokumentation Benutzung ist weiterhin umständlich Codeception bietet High-Level-Browser-Tests mit und ohne Selenium unterstützt u.a. Chromedriver und PhpBrowser
None
Infrastruktur
https://github.com/oliverklee/tea
composer.json "require-dev": { "typo3/cms-fluid-styled-content": "^7.6.23 || ^8.7.10", "helhum/typo3-composer-setup": "^0.5.1", "helmich/typo3-typoscript-lint":
"^1.4.4", "nimut/testing-framework": "^3.0", "roave/security-advisories": "dev-master" },
Konfiguration in PhpStorm
Konfiguration in PhpStorm Unit-Tests Funktionale Tests
None
Funktionale Repository- Tests
TeaRepositoryTest.php class TeaRepositoryTest extends FunctionalTestCase { /** * @var string[]
*/ protected $testExtensionsToLoad = ['typo3conf/ext/tea'];
TeaRepositoryTest.php protected function setUp() { parent::setUp(); $this->persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class); /**
@var ObjectManager $objectManager */ $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $this->subject = $objectManager->get(TeaRepository::class); } /** * @test */ public function findAllForNoRecordsReturnsEmptyContainer() { $container = $this->subject->findAll(); static::assertCount(0, $container); }
TeaRepositoryTest.php /** * @test */ public function findAllWithRecordsFindsRecordsFromAllPages() { $this->importDataSet(
__DIR__ . '/../Fixtures/Product/Tea.xml' ); $container = $this->subject->findAll(); static::assertGreaterThanOrEqual(1, \count($container)); }
Fixtures/Product/Tea.xml <?xml version="1.0" encoding="utf-8"?> <dataset> <tx_tea_domain_model_product_tea> <uid>1</uid> <pid>1</pid> <title>Earl Grey</title>
<description>Fresh and hot.</description> </tx_tea_domain_model_product_tea> … <sys_file_reference> <uid>1</uid> <pid>1</pid> <uid_foreign>3</uid_foreign> <tablenames>tx_tea_domain_model_product_tea</tablenames> <fieldname>image</fieldname> <l10n_diffsource></l10n_diffsource> </sys_file_reference> </dataset>
TeaRepositoryTest.php /** * @test */ public function findByUidForExistingRecordReturnsModelWithData() { $this->importDataSet(
__DIR__ . '/../Fixtures/Product/Tea.xml' ); $uid = 1; /** @var Tea $model */ $model = $this->subject->findByUid($uid); static::assertNotNull($model); static::assertSame('Earl Grey', $model->getTitle()); static::assertSame( 'Fresh and hot.’, $model->getDescription() ); }
TeaRepositoryTest.php /** * @test */ public function fillsImageRelation() { $this->importDataSet(
__DIR__ . '/../Fixtures/Product/Tea.xml' ); $uid = 3; /** @var Tea $model */ $model = $this->subject->findByUid($uid); $image = $model->getImage(); static::assertInstanceOf(FileReference::class, $image); static::assertSame(1, $image->getUid()); }
TeaRepositoryTest.php /** * @test */ public function addAndPersistAllCreatesNewRecord() { $title
= 'Godesberger Burgtee'; $model = new Tea(); $model->setTitle($title); $this->subject->add($model); $this->persistenceManager->persistAll(); $databaseRow = $this->getDatabaseConnection() ->selectSingleRow( '*', 'tx_tea_domain_model_product_tea', 'uid = ' . $model->getUid() ); static::assertSame($title, $databaseRow['title']); }
Legacy- Projekte
Wo anfangen?
Ein Test-Grundgerüst schaffen Testing- Framework einbinden Starter-Test assertSame(1,1); Unit-Tests Model-Tests
auf AbstractEntity Functional Tests Repository-Tests für das Laden von Models
„Low-hanging fruit“ pflücken Model-Tests für Getter/Setter (Live-Templates) Utility-Klassen Unit-Tests oder
funktionale Tests Controller-Tests Forwards und Redirects mit partiellen Mocks Repositories funktionale Tests fürs das Mappen von Feldern Controller-Tests Datenfluss: Views <=> Repositories
Wichtige Tests schreiben Hohes Risiko Was darf auf gar keinen
Fall kaputtgehen? Fragilität Was geht öfter mal kaputt? Beweglichkeit Welchen Code verändern wir oft?
Wenn man ohnehin schraubt … Bugfixes neue Features Refactoring Zuerst
Tests schreiben!
None