tdd katas in magento 2 · pdf fileplease come talk to me! :) (testing, fp, running, bee...
TRANSCRIPT
TDD Katas in Magento 2
TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
Please come talk to me! :)(testing, FP, running, bee keeping, anything ...)
TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
Code Kata TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
Code Kata? TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
We practice our craft.
TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
Like train like athletes do.
TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
What do we train in a code kata?
TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
The Mind The 3 phases of TDD Working in small units Recognizing patterns
TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
The Body Keyboard shortcuts
Efficient grouping of actions
TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
Framework Knowledge Memorizing framework sections
TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
Today's Kata:
Magento 2 Total Model
TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
Training Module: Example_GiftItem
When a customer adds a product from thesample data "Bags" attribute set,
to the cart, also add a free water bottle.
https://github.com/Vinai/module-example-giftitem
TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
https://github.com/Vinai/module-example-giftitem/tree/beginning-of-kata
Training Module: Example_GiftItem
The GiftItem total model is responsiblefor setting the price of gift items to zero
and adjusting the subtotal.
https://github.com/Vinai/module-example-giftitem
TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
https://github.com/Vinai/module-example-giftitem/tree/beginning-of-kata
What does this kata teach?
TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
(1/2) Generic skills:
TDD Red-Green-Refactor process Working with test doubles Separating pure functions from functions with side effects
TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
(2/2) Magento skills:
Test driving Magento development The Magento totals architecture
Dealing with Law of Demeter violations
TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
Kata Task:Use TDD to create the GiftItem total model
Model\Totals\GiftItemAddressTotal
Implement the collect() method.
TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
Target behavior: collect() Subtract gift item row totals sum and
base row totals sum from the subtotal
Set calculation_priceand base_calculation_priceof every gift item to zero
Call calcRowTotal on each gift
TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
Getting started:# Create module dirmkdir -p app/code/Example && cd app/code/Example
# Clone repogit clone https://github.com/Vinai/module-example-giftitem.git GiftItemcd GiftItem
# Check out git taggit checkout beginning-of-kata
TDD Magento 2 Kata - [email protected] - twitter://vinaikopp
Enjoy the session andfeel those reflexes
get sharper!
TDD Magento 2 Kata - [email protected] - twitter://vinaikopp