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
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
Gewaltfreie Kommunikation: ein Crashkurs
oliverklee
0
130
Team-Management-Plattform
oliverklee
0
93
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
社内の7割が使うデータ基盤を、 データチーム2人で回すためにやったこと
koh_yoshi
4
1.2k
FPGAが実現する遠方宇宙の高空間分解能天体撮影 -大型地上望遠鏡の視力を補正する「補償光学」とは?-
komei_mt
0
180
AI ネイティブな組織に Gemini Enterprise Agent Platform がなぜ必要なのか
asei
1
190
侵入は突然に 〜 IoTマルウェアと悪用される家庭の機器 ~ / When Intrusion Strikes: IoT Malware and the Abuse of Home Devices
nttcom
0
1.5k
名古屋の市バスGTFS-JPデータ×スガキヤ 最寄りバス停検索をAmazon ElastiCache Serverless for Valkeyで最適化する
usanchuu
1
500
FORENSIA: ローカルLLMフォレンジックハーネス
sumeshi
2
350
AIは実装を速くする。では、私たちは何を今作るべきか?-立場を越えてリリースに向き合ったチーム開発の実践 / 20260801 Hiromi Nakaya and Naoki Takahashi
shift_evolve
PRO
3
450
Data Hubグループ 紹介資料
sansan33
PRO
0
3.1k
制約理論(ToC)入門 2026版
recruitengineers
PRO
6
2k
もう一度考える SRE チームの作り方・育て方 / Rethinking SRE #1: Building and Growing SRE Teams
rrreeeyyy
6
1k
QAエンジニア起点で進める、SmartHRにおける信頼性向上について
kaomi_wombat
1
120
今こそ聞きたいソフトウェア設計 ドメイン駆動設計再入門
masuda220
PRO
17
6.8k
Featured
See All Featured
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
200
Faster Mobile Websites
deanohume
310
32k
Crafting Experiences
bethany
1
240
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
64
56k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.5k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
2
3.7k
Designing Powerful Visuals for Engaging Learning
tmiket
1
480
Documentation Writing (for coders)
carmenintech
77
5.4k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
330
Amusing Abliteration
ianozsvald
1
240
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