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
Unit testing with TYPO3
Search
Oliver Klee
October 25, 2015
Technology
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Unit testing with TYPO3
Oliver Klee
October 25, 2015
More Decks by Oliver Klee
See All by Oliver Klee
Softwarequalität für öffentliche TYPO3-Extensions
oliverklee
0
57
Psychologische Sicherheit
oliverklee
0
43
Generative KI, Ethik und Nachhaltigkeit
oliverklee
0
170
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
65
Vertrauen in Teams & Führung
oliverklee
0
190
Testing von TYPO3-Extensions
oliverklee
0
110
Other Decks in Technology
See All in Technology
継続的なAIコスト最適化
bgpat
1
340
遠藤な_めぐろLT #38 「社内のAI活用推進」@麻布台_20261009
endonanana
0
130
USB PDを使ってスマホを労わりたい
raspython3
0
180
DWH の限界突破! AI エージェント向け爆速リアルタイムデータ基盤 ClickHouse
jozono
1
480
Post AI時代のリファクタリング実践記 / Refactoring in the post AI era
kaminashi
1
260
古い指輪から広がった JAVA コミュニティ とのつながり
yamad
0
120
Gemini Intelligence 入門 ― AppFunctions と Gemini Nano
takuroabe
0
270
実践!Cloud Run ハンズオン!! / Cloud Run handson
y0hgi
2
280
Tofu-Controller lightning talk @ Containerday 2026
gionn
0
120
S3 Filesで挑む! 八戸せんべい汁の食べ頃問題
usanchuu
0
100
AI導入は済んだ。次は統制を作り替える番だ_AI×開発組織 Summit 2026
techtekt
PRO
0
290
Browser Spec: Testing Hotwire with Ruby
takahashim
1
130
Featured
See All Featured
Navigating Weather and Climate Data
rabernat
0
560
It's Worth the Effort
3n
188
29k
Automating Front-end Workflow
addyosmani
1369
210k
Six Lessons from altMBA
skipperchong
29
4.5k
The Curious Case for Waylosing
cassininazir
1
570
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
260
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
600
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
710
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
590
Building AI with AI
inesmontani
PRO
1
1.3k
Transcript
Unit testing with TYPO3 Oliver Klee, 2015-10-26 @oliklee
[email protected]
Unit tests?
Manual testing is cumbersome
Automated testing is fast
Unit tests for the Realty Manager extension
more than 1600 tests
in less than 60 seconds
Verify that your code does what you expect
Make sure that your changes won‘t break anything
Keep other coders from breaking your code
Don‘t break anything even in complex projects
Create a safety net for refactoring
Improve the structure of the code
Green feelsgood!
None
Know your tools
The phpunit extension has it all phpunit (TYPO3 extension) PHPUnit
(Composer package) Testrunner (back-end- module) Testrunner (CLI module) Testing framework for FE & DB
Let‘s get some terms straight
Test suite Test case Test Two tests meet in a
bar ... Assertion Test Test Test case
The life cycle of a unit test new FooTest(); setUp();
/** @test */ lifeIsGood(); tearDown();
4 test phases Setup Exercise Verify Teardown setUp() in the
test method call assert… tearDown() https://robots.thoughtbot.com/four-phase-test
Code test-first write test write code refactor
kata Code
Testing levels http://dabrorius.github.io/2015/06/tested-be-thy-name.html
Unit tests are small and fast
Integration tests check the interaction of components
System tests test the complete system
Test types
Blackbox tests what is visible to the outside test
Whitebox tests inner workings test the
Functional tests
Acceptance tests Selenium
Regression tests
Smoke tests
Smoke tests
Use meaningful unit test names classCanBeInstantiated setTitleSetsTitle setSizeWithZeroThrowsException hasTitleForEmptyTitleReturnsFalse Name
the behavior. Name the preconditions. Mention the method. Dont‘t use "works" or "correctly". measureFrubbleWorksCorrectly
The testing framework is created quickly /** * @var Tx_Phpunit_Framework
*/ protected $testingFramework = NULL; protected function setUp() { $this->testingFramework = new Tx_Phpunit_Framework('tx_news2'); } protected function tearDown() { $this->testingFramework->cleanUp(); } CREATE TABLE tx_news2_domain_model_news ( … is_dummy_record tinyint(1) unsigned DEFAULT '0' NOT NULL, … discard the FE, delete DB records, delete files
$recordUid = $tf->createRecord($tableName, array $recordData = array()); The testing framework
can fake almost everything $tf->changeRecord($tableName, $uid, array $recordData); $tf->deleteRecord($tableName, $uid); $tf->createRelation($tableName, $uidLocal, $uidForeign, $sorting = 0); $tf->createRelationAndUpdateCounter($tableName, $uidLocal, $uidForeign, $columnName); $tf->removeRelation($tableName, $uidLocal, $uidForeign); $numberOfRecords = $tf->countRecords($tableName, $whereClause = ''); $success = $tf->existsRecord($tableName, $whereClause = ''); $success = $tf->existsRecordWithUid($tableName, $uid); $success = $tf->existsExactlyOneRecord($tableName, $whereClause = '');
$groupUid = $tf->createFrontEndUserGroup(array $recordData = array()); $userUid = $tf->createFrontEndUser($groups =
'', array $recordData = array()); $userUid = $tf->createAndLoginFrontEndUser($groups = '', array $recordData = array()); $pageUid = $tf->createFrontEndPage($parentId = 0, array $recordData = array()); $pageUid = $tf->createSystemFolder($parentId = 0, array $recordData = array()); $elementUid = $tf->createContentElement($pageId = 0, array $recordData = array()); $tf->createTemplate($pageId, array $recordData = array()); $pageUid = $tf->createFakeFrontEnd($pageUid = 0); $tf->discardFakeFrontEnd(); $tf->loginFrontEndUser($userId); $tf->logoutFrontEndUser(); $isLoggedIn = $tf->isLoggedIn(); The testing framework can fake almost everything
$recordUid = $tf->createBackEndUser(array $recordData = array()); $recordUid = $tf->createBackEndUserGroup(array $recordData
= array()); The testing framework can fake almost everything
$path = $tf->createDummyFile($fileName = 'test.txt', $content = ''); $path =
$tf->createDummyZipArchive($fileName = 'test.zip', array $filesToAdd = array()); $tf->deleteDummyFile($fileName); $tf->deleteDummyFolder($folderName); $path = $tf->createDummyFolder($folderName); The testing framework can fake almost everything
None