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
Transcript
42 slides
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
More Decks by Oliver Klee
See All by Oliver Klee
Testing von TYPO3-Extensions
oliverklee
0
34
Softwarequalität für öffentliche TYPO3-Extensions
oliverklee
0
86
Psychologische Sicherheit
oliverklee
0
53
Generative KI, Ethik und Nachhaltigkeit
oliverklee
0
300
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
160
Team-Management-Plattform
oliverklee
0
110
Vertrauen in Teams & Führung
oliverklee
0
340
Software-Qualität von TYPO3-Extensions automatisieren
oliverklee
0
73
Vertrauen in Teams & Führung
oliverklee
0
200
Other Decks in Technology
See All in Technology
個人ASを取得して、自宅Kubernetes上のVMをグローバルIPで公開した話
munenick
0
230
専門家に使ってもらうAIプロダクトをつくる - 病院の医事課向けDPCコーディング支援システムの設計と評価
hagino3000
4
1k
SBOM 生成ツールで 2026 Minimum Elements はどこまで満たせるのか
gokken
0
160
認知の質も文化醸成も。数年取り組んで見えてきた技術広報のKPI設計 / Tech PR KPIs: Lessons on Awareness Quality and Culture After Several Years
bitkey
PRO
0
210
From vibe coding to reliable (agentic) development
jcabot
0
220
Kansai WordPress Meetup@大阪『ブロックテーマを作る上で知っておくべきこと
torounit
0
310
Taking back control of your AI development
inesmontani
PRO
0
310
AIエージェントのアーキテクチャ設計
nsatoh
0
490
社内アプリ基盤「Quartz」による、 非エンジニアとAIに本番デプロイを 任せても壊れないプラットフォームの設計
staka121
PRO
1
230
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
17
120k
市販IoT機器や自作IoT機器とHomeAssistantを駆使して家の電気代をできる限り見える化する方法の考案
harutiro
0
410
農家は秘伝のタレを知らない - NOBODY KNOWS THE HIDDEN SOURCE - Kaggriculture 3rd Place Solution
masspeaks
3
680
Featured
See All Featured
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
360
The World Runs on Bad Software
bkeepers
PRO
72
12k
SEO for Brand Visibility & Recognition
aleyda
0
4.9k
The Art of Programming - Codeland 2020
erikaheidi
57
15k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.5k
Design in an AI World
tapps
1
400
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
450
Un-Boring Meetings
codingconduct
0
510
YesSQL, Process and Tooling at Scale
rocio
174
15k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
570
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
エンジニアに許された特別な時間の終わり
watany
109
250k