Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Testen mit TYPO3 für Fortgeschrittene
Search
Oliver Klee
May 30, 2018
Technology
230
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
Psychologische Sicherheit
oliverklee
0
40
Generative KI, Ethik und Nachhaltigkeit
oliverklee
0
110
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
140
Team-Management-Plattform
oliverklee
0
100
Vertrauen in Teams & Führung
oliverklee
0
330
Software-Qualität von TYPO3-Extensions automatisieren
oliverklee
0
64
Vertrauen in Teams & Führung
oliverklee
0
190
Testing von TYPO3-Extensions
oliverklee
0
110
Software-Qualität von Extensions automatisieren
oliverklee
1
68
Other Decks in Technology
See All in Technology
検証フェーズはAIの回答を判断するための学習機会
toru_kubota
2
550
実体験から学ぶ分析エージェントの開発と運⽤
recruitengineers
PRO
8
1.9k
ビジネスを止めない技術的負債の返済のための戦略とその手法 - 技術的負債と向き合う / Complexity and Simplicity
soudai
PRO
3
680
購入ドメインでの課題と取り組み
ykagano
0
150
自作バイナリを動かす「入口」8選
puhitaku
1
1.2k
3つのアプローチで目指す チームを強くするAI駆動開発
thkt
0
150
Codex概要
ymiya55
0
490
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
0
220
[AWS 秋のクラウドオペレーション祭り 2026]AWS DevOps Agentで変わるリリースと運用対応 ~リリース管理機能と Directed actions のご紹介~
furuton
4
1.2k
SDDの運用にめげずに向き合った話
sansantech
PRO
1
140
Incremental HTTP
kazuho
5
2.1k
AI時代のPRレビューにどう向き合うか?
kairim0
1
130
Featured
See All Featured
Paper Plane
katiecoart
PRO
4
54k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
560
Optimizing for Happiness
mojombo
378
71k
We Are The Robots
honzajavorek
0
390
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
[SF Ruby Conf 2025] Rails X
palkan
3
1.4k
Exploring anti-patterns in Rails
aemeredith
4
530
Game over? The fight for quality and originality in the time of robots
wayneb77
1
300
Optimising Largest Contentful Paint
csswizardry
37
4k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
510
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
590
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