SlideShare a Scribd company logo
1 of 54
Kristof Ringleff / Director @ Fooman
Growing Up With Magento
Leveraging Magento 2 to improve your extensions
Technologies – Magento 1.0
<?xml ?>
Technologies – Magento 2.0
<?xml ?>
Best practice today
Required tomorrow
Outdated the day after
No substitute for
continuously learning
and improving
Growing Up With Magento
Leveraging Magento 2 to improve your extensions
About Me
The German Connection
2004
1. Growing Up
2. Learning from Magento
3. Learning with the Community
1. Growing Up
Invest in yourself
Invest in yourself
4 hour challenge
Payback period 12 weeks
2. Learning from Magento
Dependency Injection
Service Contracts
Unit Testing
Integration Tests
Functional Tests
Mage::getModel() et al
Dependency
Injection
class SingletonExample
{
protected $singleton;
public function __construct(
Singleton $singleton
) {
$this->singleton = $singleton;
}
}
$objectManager->get('FoomanDiExamplesModelSingleton');
behind the scenes:
class ModelExample
{
protected $model;
public function __construct(
Model $model
) {
$this->model = $model;
}
}
$objectManager->create('FoomanDiExamplesModelModel');
behind the scenes:
class ModelExample
{
protected $model;
public function __construct(
Model $model
) {
$this->model = $model;
}
}
$objectManager->create('FoomanDiExamplesModelModel');
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="FoomanDiExamplesModelModel" shared="false" />
</config>
behind the scenes:
Executive Summary Dependency Injection
• Constructor based with Magento flavour
• di.xml
• Use Interfaces wherever possible
• Don’t use the ObjectManager directly
Create your Service Contracts
with 2 Ingredients
Magento 1.0
0 Unit Tests
0 Integration Tests
0 Functional Tests
Magento 2.0
15K Unit Tests
3.5K Integration Tests
300 Functional Test Scenarios
Unit Testing
Integration Tests
<?php
namespace FoomanPrintOrderPdfControllerAdminhtmlOrder;
/**
* @magentoAppArea adminhtml
*/
class PrintActionTest extends MagentoTestFrameworkTestCaseAbstractBackendController
{
public function setUp()
{
$this->resource = 'Magento_Sales::sales_order';
$this->uri = 'backend/fooman_printorderpdf/order/print';
parent::setUp();
}
}
public function testAclHasAccess()
{
if ($this->uri === null) {
$this->markTestIncomplete('AclHasAccess test is not complete');
}
$this->dispatch($this->uri);
$this->assertNotSame(403, $this->getResponse()->getHttpResponseCode());
$this->assertNotSame(404, $this->getResponse()->getHttpResponseCode());
}
public function testAclNoAccess()
{
if ($this->resource === null) {
$this->markTestIncomplete('Acl test is not complete');
}
$this->_objectManager->get('MagentoFrameworkAclBuilder’)->getAcl()
->deny(null, $this->resource);
$this->dispatch($this->uri);
$this->assertSame(403, $this->getResponse()->getHttpResponseCode());
}
public function testInvoiceNumberWithoutPrefix()
{
/** @var MagentoSalesApiDataOrderInterface $order */
$order = $this->objectManager->create('MagentoSalesApiDataOrderInterface')
->load('100000001', 'increment_id');
/** @var MagentoSalesApiInvoiceManagementInterface $invoiceMgmt */
$invoiceMgmt = $this->objectManager-
>get('MagentoSalesApiInvoiceManagementInterface');
$invoice = $invoiceMgmt ->prepareInvoice($order);
/** @var MagentoSalesApiInvoiceRepositoryInterface $invoiceRepo */
$invoiceRepo = $this->objectManager-
>get('MagentoSalesApiInvoiceRepositoryInterface');
$invoiceRepo ->save($invoice);
$this->assertEquals('100000001', $invoice->getIncrementId());
}
/**
* @magentoDataFixture Magento/Sales/_files/order.php
*/
public function testInvoiceNumberWithoutPrefix()
{
/** @var MagentoSalesApiDataOrderInterface $order */
$order = $this->objectManager->create('MagentoSalesApiDataOrderInterface')
->load('100000001', 'increment_id');
/** @var MagentoSalesApiInvoiceManagementInterface $invoiceMgmt */
$invoiceMgmt = $this->objectManager-
>get('MagentoSalesApiInvoiceManagementInterface');
$invoice = $invoiceMgmt ->prepareInvoice($order);
/** @var MagentoSalesApiInvoiceRepositoryInterface $invoiceRepo */
$invoiceRepo = $this->objectManager-
>get('MagentoSalesApiInvoiceRepositoryInterface');
$invoiceRepo ->save($invoice);
$this->assertEquals('100000001', $invoice->getIncrementId());
}
!broken != working
Functional Tests
<?php
namespace FoomanGoogleAnalyticsPlusTestTestCase;
use MagentoMtfTestCaseScenario;
class CreateGaOrderTest extends Scenario
{
public function test()
{
$this->executeScenario();
}
}
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/TestCase/etc/testcase.xsd">
<scenario name="CreateGaOrderTest" firstStep="setupConfiguration">
<step name="setupConfiguration" module="Magento_Config" next="createProducts"/>
<step name="createProducts" module="Magento_Catalog" next="createTaxRule"/>
<step name="createTaxRule" module="Magento_Tax" next="addProductsToTheCart"/>
<step name="addProductsToTheCart" module="Magento_Checkout" next="estimateShippingAndTax"/>
<step name="estimateShippingAndTax" module="Magento_Checkout" next="clickProceedToCheckout"/>
<step name="clickProceedToCheckout" module="Magento_Checkout" next="createCustomer"/>
<step name="createCustomer" module="Magento_Customer" next="selectCheckoutMethod"/>
<step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress"/>
<step name="fillShippingAddress" module="Magento_Checkout" next="fillShippingMethod"/>
<step name="fillShippingMethod" module="Magento_Checkout" next="selectPaymentMethod"/>
<step name="selectPaymentMethod" module="Magento_Checkout" next="fillBillingInformation"/>
<step name="fillBillingInformation" module="Magento_Checkout" next="placeOrder"/>
<step name="placeOrder" module="Magento_Checkout"/>
</scenario>
</config>
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/TestCase/etc/testcase.xsd">
<scenario name="CreateGaOrderTest" firstStep="setupConfiguration">
<step name="setupConfiguration" module="Magento_Config" next="createProducts"/>
<step name="createProducts" module="Magento_Catalog" next="createTaxRule"/>
<step name="createTaxRule" module="Magento_Tax" next="addProductsToTheCart"/>
<step name="addProductsToTheCart" module="Magento_Checkout" next="estimateShippingAndTax"/>
<step name="estimateShippingAndTax" module="Magento_Checkout" next="clickProceedToCheckout"/>
<step name="clickProceedToCheckout" module="Magento_Checkout" next="createCustomer"/>
<step name="createCustomer" module="Magento_Customer" next="selectCheckoutMethod"/>
<step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress"/>
<step name="fillShippingAddress" module="Magento_Checkout" next="fillShippingMethod"/>
<step name="fillShippingMethod" module="Magento_Checkout" next="selectPaymentMethod"/>
<step name="selectPaymentMethod" module="Magento_Checkout" next="fillBillingInformation"/>
<step name="fillBillingInformation" module="Magento_Checkout" next="placeOrder"/>
<step name="placeOrder" module="Magento_Checkout"/>
</scenario>
</config>
<?xml version="1.0" encoding="utf-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
<testCase name="FoomanGoogleAnalyticsPlusTestTestCaseCreateGaOrderTest"
summary="Create Order and check transaction tracking" ticketId="">
<variation name="CreateOrderTestTrackingEnabled" summary="Place an order">
<data name="products" xsi:type="string">catalogProductSimple::default</data>
<data name="customer/dataset" xsi:type="string">default</data>
<data name="checkoutMethod" xsi:type="string">guest</data>
<data name="shippingAddress/dataset" xsi:type="string">UK_address</data>
<data name="shipping/shippin99g_service" xsi:type="string">Flat Rate</data>
<data name="shipping/shipping_method" xsi:type="string">Fixed</data>
<data name="prices" xsi:type="array">
<item name="grandTotal" xsi:type="string">565.00</item>
</data>
<data name="payment/method" xsi:type="string">checkmo</data>
<data name="status" xsi:type="string">Pending</data>
<data name="configData" xsi:type="string">google_universal_enabled</data>
<constraint name="FoomanGoogleAnalyticsPlusTestConstraintAssertEcTracking" />
</variation>
</testCase>
</config>
<?xml version="1.0" encoding="utf-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
<testCase name="FoomanGoogleAnalyticsPlusTestTestCaseCreateGaOrderTest"
summary="Create Order and check transaction tracking" ticketId="">
<variation name="CreateOrderTestTrackingEnabled" summary="Place an order">
<data name="products" xsi:type="string">catalogProductSimple::default</data>
<data name="customer/dataset" xsi:type="string">default</data>
<data name="checkoutMethod" xsi:type="string">guest</data>
<data name="shippingAddress/dataset" xsi:type="string">UK_address</data>
<data name="shipping/shippin99g_service" xsi:type="string">Flat Rate</data>
<data name="shipping/shipping_method" xsi:type="string">Fixed</data>
<data name="prices" xsi:type="array">
<item name="grandTotal" xsi:type="string">565.00</item>
</data>
<data name="payment/method" xsi:type="string">checkmo</data>
<data name="status" xsi:type="string">Pending</data>
<data name="configData" xsi:type="string">google_universal_enabled</data>
<constraint name="FoomanGoogleAnalyticsPlusTestConstraintAssertEcTracking" />
</variation>
</testCase>
</config>
<?php
namespace FoomanGoogleAnalyticsPlusTestConstraint;
use MagentoCheckoutTestPageCheckoutOnepageSuccess;
class AssertEcTrackingIsPresent extends MagentoMtfConstraintAbstractConstraint
{
const GA_EC = "ga('ec:setAction', 'purchase'";
public function processAssert(CheckoutOnepageSuccess $checkoutOnepageSuccess)
{
PHPUnit_Framework_Assert::assertContains(
self::GA_EC,
$checkoutOnepageSuccess->getFoomanBody()->getGaScript(),
'Ecommerce Tracking is not present.'
);
}
}
On error automatically
saves:
Screenshot
+ Page HTML
$order = $this->fixtureFactory->createByCode(
'orderInjectable',
['dataset' => 'default']
);
$order->persist();
$order = $this->fixtureFactory->createByCode(
'orderInjectable',
['dataset' => 'default']
);
$order->persist();
$order = $this->fixtureFactory->createByCode(
'orderInjectable',
['dataset' => with_coupon']
);
$order->persist();
$order = $this->fixtureFactory->createByCode(
'orderInjectable',
['dataset' => 'default']
);
$order->persist();
$order = $this->fixtureFactory->createByCode(
'orderInjectable',
['dataset' => with_coupon']
);
$order->persist();
$order = $this->fixtureFactory->createByCode(
'orderInjectable',
['dataset' => virtual_product']
);
$order->persist();
3. Learning with the Community
Composer + Semantic Versioning
PSR-X
Get involved
PHP is growing up too
Composer
+
Semantic Versioning
=
Love
My Version N
My Version N+1
PSR-X
Don’t be the IE of developers
php-cs-fixer fix --level=psr2 .
Best way to keep learning?
Get involved!
magento.stackexchange.com
Open source some code
1. Growing Up
Invest in yourself
2. Learning from Magento
Dependency Injection
Use and create your own Service Contracts
Leverage Test Frameworks
3. Learning with the Community
Composer + Semantic Versioning
PSR-X
Get involved
Questions?
or later via
@foomanNZ
kristof@fooman.co.nz

More Related Content

What's hot

Technology and Science News - ABC News
Technology and Science News - ABC NewsTechnology and Science News - ABC News
Technology and Science News - ABC Newsalertchair8725
 
Fixing Magento Core for Better Performance - Ivan Chepurnyi
Fixing Magento Core for Better Performance - Ivan ChepurnyiFixing Magento Core for Better Performance - Ivan Chepurnyi
Fixing Magento Core for Better Performance - Ivan ChepurnyiMeet Magento Spain
 
Optimization in django orm
Optimization in django ormOptimization in django orm
Optimization in django ormDenys Levchenko
 
Pruebas unitarias con django
Pruebas unitarias con djangoPruebas unitarias con django
Pruebas unitarias con djangoTomás Henríquez
 
International News | World News
International News | World NewsInternational News | World News
International News | World Newsjoblessbeach6696
 
Technology and Science News - ABC News
Technology and Science News - ABC NewsTechnology and Science News - ABC News
Technology and Science News - ABC Newstalloration5719
 
Business News, Personal Finance and Money News
Business News, Personal Finance and Money NewsBusiness News, Personal Finance and Money News
Business News, Personal Finance and Money Newseminentoomph4388
 
International News | World News
International News | World NewsInternational News | World News
International News | World Newswrathfulmedal3110
 
Effective Android Data Binding
Effective Android Data BindingEffective Android Data Binding
Effective Android Data BindingEric Maxwell
 
Zf2 how arrays will save your project
Zf2   how arrays will save your projectZf2   how arrays will save your project
Zf2 how arrays will save your projectMichelangelo van Dam
 
Home and Garden | Home Improvement and Decorating Tips
Home and Garden | Home Improvement and Decorating TipsHome and Garden | Home Improvement and Decorating Tips
Home and Garden | Home Improvement and Decorating Tipsshortguidebook822
 
Introduction to Zend Framework web services
Introduction to Zend Framework web servicesIntroduction to Zend Framework web services
Introduction to Zend Framework web servicesMichelangelo van Dam
 
Modern Android Architecture
Modern Android ArchitectureModern Android Architecture
Modern Android ArchitectureEric Maxwell
 
What Would You Do? With John Quinones
What Would You Do? With John QuinonesWhat Would You Do? With John Quinones
What Would You Do? With John Quinonesalertchair8725
 
What Would You Do? With John Quinones
What Would You Do? With John QuinonesWhat Would You Do? With John Quinones
What Would You Do? With John Quinonesnumberlesspasto93
 
Optimizing Magento by Preloading Data
Optimizing Magento by Preloading DataOptimizing Magento by Preloading Data
Optimizing Magento by Preloading DataIvan Chepurnyi
 
Making Magento flying like a rocket! (A set of valuable tips for developers)
Making Magento flying like a rocket! (A set of valuable tips for developers)Making Magento flying like a rocket! (A set of valuable tips for developers)
Making Magento flying like a rocket! (A set of valuable tips for developers)Ivan Chepurnyi
 
How I started to love design patterns
How I started to love design patternsHow I started to love design patterns
How I started to love design patternsSamuel ROZE
 
Data20161007
Data20161007Data20161007
Data20161007capegmail
 

What's hot (20)

Technology and Science News - ABC News
Technology and Science News - ABC NewsTechnology and Science News - ABC News
Technology and Science News - ABC News
 
Fixing Magento Core for Better Performance - Ivan Chepurnyi
Fixing Magento Core for Better Performance - Ivan ChepurnyiFixing Magento Core for Better Performance - Ivan Chepurnyi
Fixing Magento Core for Better Performance - Ivan Chepurnyi
 
Optimization in django orm
Optimization in django ormOptimization in django orm
Optimization in django orm
 
Pruebas unitarias con django
Pruebas unitarias con djangoPruebas unitarias con django
Pruebas unitarias con django
 
International News | World News
International News | World NewsInternational News | World News
International News | World News
 
QA for PHP projects
QA for PHP projectsQA for PHP projects
QA for PHP projects
 
Technology and Science News - ABC News
Technology and Science News - ABC NewsTechnology and Science News - ABC News
Technology and Science News - ABC News
 
Business News, Personal Finance and Money News
Business News, Personal Finance and Money NewsBusiness News, Personal Finance and Money News
Business News, Personal Finance and Money News
 
International News | World News
International News | World NewsInternational News | World News
International News | World News
 
Effective Android Data Binding
Effective Android Data BindingEffective Android Data Binding
Effective Android Data Binding
 
Zf2 how arrays will save your project
Zf2   how arrays will save your projectZf2   how arrays will save your project
Zf2 how arrays will save your project
 
Home and Garden | Home Improvement and Decorating Tips
Home and Garden | Home Improvement and Decorating TipsHome and Garden | Home Improvement and Decorating Tips
Home and Garden | Home Improvement and Decorating Tips
 
Introduction to Zend Framework web services
Introduction to Zend Framework web servicesIntroduction to Zend Framework web services
Introduction to Zend Framework web services
 
Modern Android Architecture
Modern Android ArchitectureModern Android Architecture
Modern Android Architecture
 
What Would You Do? With John Quinones
What Would You Do? With John QuinonesWhat Would You Do? With John Quinones
What Would You Do? With John Quinones
 
What Would You Do? With John Quinones
What Would You Do? With John QuinonesWhat Would You Do? With John Quinones
What Would You Do? With John Quinones
 
Optimizing Magento by Preloading Data
Optimizing Magento by Preloading DataOptimizing Magento by Preloading Data
Optimizing Magento by Preloading Data
 
Making Magento flying like a rocket! (A set of valuable tips for developers)
Making Magento flying like a rocket! (A set of valuable tips for developers)Making Magento flying like a rocket! (A set of valuable tips for developers)
Making Magento flying like a rocket! (A set of valuable tips for developers)
 
How I started to love design patterns
How I started to love design patternsHow I started to love design patterns
How I started to love design patterns
 
Data20161007
Data20161007Data20161007
Data20161007
 

Viewers also liked

Bureau Klantzicht Presentatie
Bureau Klantzicht PresentatieBureau Klantzicht Presentatie
Bureau Klantzicht PresentatieJoàn Harms 1200+
 
Weapons of mass innovation | By Raphael H. Cohen | Costa Rica handout
Weapons of mass innovation | By Raphael H. Cohen | Costa Rica handoutWeapons of mass innovation | By Raphael H. Cohen | Costa Rica handout
Weapons of mass innovation | By Raphael H. Cohen | Costa Rica handoutCAMTIC
 
Língua port. ii sociolinguística
Língua port. ii   sociolinguísticaLíngua port. ii   sociolinguística
Língua port. ii sociolinguísticaAnyellen Mendanha
 
CAMTIC English Presentation (Enero, 2011)
CAMTIC English Presentation (Enero, 2011)CAMTIC English Presentation (Enero, 2011)
CAMTIC English Presentation (Enero, 2011)CAMTIC
 
ProIdeal Plus: First Annual Project Review Meeting
ProIdeal Plus: First Annual Project Review MeetingProIdeal Plus: First Annual Project Review Meeting
ProIdeal Plus: First Annual Project Review MeetingCAMTIC
 
Bureau Klantzicht @ www.bureauklantzicht.nl
Bureau Klantzicht @ www.bureauklantzicht.nlBureau Klantzicht @ www.bureauklantzicht.nl
Bureau Klantzicht @ www.bureauklantzicht.nlJoàn Harms 1200+
 

Viewers also liked (18)

Kids Avoir1
Kids Avoir1Kids Avoir1
Kids Avoir1
 
Bureau Klantzicht Presentatie
Bureau Klantzicht PresentatieBureau Klantzicht Presentatie
Bureau Klantzicht Presentatie
 
Kids Adj Ppt 1
Kids Adj Ppt 1Kids Adj Ppt 1
Kids Adj Ppt 1
 
In The
In TheIn The
In The
 
Kids Avoir
Kids AvoirKids Avoir
Kids Avoir
 
Weapons of mass innovation | By Raphael H. Cohen | Costa Rica handout
Weapons of mass innovation | By Raphael H. Cohen | Costa Rica handoutWeapons of mass innovation | By Raphael H. Cohen | Costa Rica handout
Weapons of mass innovation | By Raphael H. Cohen | Costa Rica handout
 
Kids Avoir1
Kids Avoir1Kids Avoir1
Kids Avoir1
 
Growing up with Magento
Growing up with MagentoGrowing up with Magento
Growing up with Magento
 
Learnin\'
Learnin\'Learnin\'
Learnin\'
 
Little-Bird
Little-BirdLittle-Bird
Little-Bird
 
Língua port. ii sociolinguística
Língua port. ii   sociolinguísticaLíngua port. ii   sociolinguística
Língua port. ii sociolinguística
 
CAMTIC English Presentation (Enero, 2011)
CAMTIC English Presentation (Enero, 2011)CAMTIC English Presentation (Enero, 2011)
CAMTIC English Presentation (Enero, 2011)
 
ProIdeal Plus: First Annual Project Review Meeting
ProIdeal Plus: First Annual Project Review MeetingProIdeal Plus: First Annual Project Review Meeting
ProIdeal Plus: First Annual Project Review Meeting
 
Tigo
TigoTigo
Tigo
 
Kids English 9
Kids English 9Kids English 9
Kids English 9
 
Bureau Klantzicht
Bureau KlantzichtBureau Klantzicht
Bureau Klantzicht
 
Bureau Klantzicht @ www.bureauklantzicht.nl
Bureau Klantzicht @ www.bureauklantzicht.nlBureau Klantzicht @ www.bureauklantzicht.nl
Bureau Klantzicht @ www.bureauklantzicht.nl
 
Verb Subject Agreement
Verb Subject AgreementVerb Subject Agreement
Verb Subject Agreement
 

Similar to Meet Magento DE 2016 - Kristof Ringleff - Growing up with Magento

Magento Performance Toolkit
Magento Performance ToolkitMagento Performance Toolkit
Magento Performance ToolkitSergii Shymko
 
Curso Symfony - Clase 4
Curso Symfony - Clase 4Curso Symfony - Clase 4
Curso Symfony - Clase 4Javier Eguiluz
 
Magento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowMagento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowVrann Tulika
 
Using of TDD practices for Magento
Using of TDD practices for MagentoUsing of TDD practices for Magento
Using of TDD practices for MagentoIvan Chepurnyi
 
Symfony 4 Workshop - Limenius
Symfony 4 Workshop - LimeniusSymfony 4 Workshop - Limenius
Symfony 4 Workshop - LimeniusIgnacio Martín
 
How to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento ExtensionHow to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento ExtensionHendy Irawan
 
Magento 2 integration tests
Magento 2 integration testsMagento 2 integration tests
Magento 2 integration testsDusan Lukic
 
Morgagebuildclasses.netbeans_automatic_buildMorgagebui.docx
Morgagebuildclasses.netbeans_automatic_buildMorgagebui.docxMorgagebuildclasses.netbeans_automatic_buildMorgagebui.docx
Morgagebuildclasses.netbeans_automatic_buildMorgagebui.docxgilpinleeanna
 
Utilization of zend an ultimate alternate for intense data processing
Utilization of zend  an ultimate alternate for intense data processingUtilization of zend  an ultimate alternate for intense data processing
Utilization of zend an ultimate alternate for intense data processingCareer at Elsner
 
Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Eric Hogue
 
How I started to love design patterns
How I started to love design patternsHow I started to love design patterns
How I started to love design patternsSamuel ROZE
 
Magento 2 Seminar - Anton Kril - Magento 2 Summary
Magento 2 Seminar - Anton Kril - Magento 2 SummaryMagento 2 Seminar - Anton Kril - Magento 2 Summary
Magento 2 Seminar - Anton Kril - Magento 2 SummaryYireo
 
Magento Dependency Injection
Magento Dependency InjectionMagento Dependency Injection
Magento Dependency InjectionAnton Kril
 
Drupal 8 Every Day: An Intro to Developing With Drupal 8
Drupal 8 Every Day: An Intro to Developing With Drupal 8Drupal 8 Every Day: An Intro to Developing With Drupal 8
Drupal 8 Every Day: An Intro to Developing With Drupal 8Acquia
 
How to create a magento controller in magento extension
How to create a magento controller in magento extensionHow to create a magento controller in magento extension
How to create a magento controller in magento extensionHendy Irawan
 
Key Insights into Development Design Patterns for Magento 2 - Magento Live UK
Key Insights into Development Design Patterns for Magento 2 - Magento Live UKKey Insights into Development Design Patterns for Magento 2 - Magento Live UK
Key Insights into Development Design Patterns for Magento 2 - Magento Live UKMax Pronko
 
Black Magic of Code Generation in Magento 2
Black Magic of Code Generation in Magento 2Black Magic of Code Generation in Magento 2
Black Magic of Code Generation in Magento 2Sergii Shymko
 

Similar to Meet Magento DE 2016 - Kristof Ringleff - Growing up with Magento (20)

Magento Performance Toolkit
Magento Performance ToolkitMagento Performance Toolkit
Magento Performance Toolkit
 
Curso Symfony - Clase 4
Curso Symfony - Clase 4Curso Symfony - Clase 4
Curso Symfony - Clase 4
 
Magento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowMagento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request Flow
 
Using of TDD practices for Magento
Using of TDD practices for MagentoUsing of TDD practices for Magento
Using of TDD practices for Magento
 
Symfony 4 Workshop - Limenius
Symfony 4 Workshop - LimeniusSymfony 4 Workshop - Limenius
Symfony 4 Workshop - Limenius
 
How to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento ExtensionHow to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento Extension
 
Magento 2 integration tests
Magento 2 integration testsMagento 2 integration tests
Magento 2 integration tests
 
Morgagebuildclasses.netbeans_automatic_buildMorgagebui.docx
Morgagebuildclasses.netbeans_automatic_buildMorgagebui.docxMorgagebuildclasses.netbeans_automatic_buildMorgagebui.docx
Morgagebuildclasses.netbeans_automatic_buildMorgagebui.docx
 
Utilization of zend an ultimate alternate for intense data processing
Utilization of zend  an ultimate alternate for intense data processingUtilization of zend  an ultimate alternate for intense data processing
Utilization of zend an ultimate alternate for intense data processing
 
Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014
 
Magento Indexes
Magento IndexesMagento Indexes
Magento Indexes
 
How I started to love design patterns
How I started to love design patternsHow I started to love design patterns
How I started to love design patterns
 
Magento 2 Seminar - Anton Kril - Magento 2 Summary
Magento 2 Seminar - Anton Kril - Magento 2 SummaryMagento 2 Seminar - Anton Kril - Magento 2 Summary
Magento 2 Seminar - Anton Kril - Magento 2 Summary
 
Magento Dependency Injection
Magento Dependency InjectionMagento Dependency Injection
Magento Dependency Injection
 
Drupal 8 Every Day: An Intro to Developing With Drupal 8
Drupal 8 Every Day: An Intro to Developing With Drupal 8Drupal 8 Every Day: An Intro to Developing With Drupal 8
Drupal 8 Every Day: An Intro to Developing With Drupal 8
 
How to create a magento controller in magento extension
How to create a magento controller in magento extensionHow to create a magento controller in magento extension
How to create a magento controller in magento extension
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
 
Key Insights into Development Design Patterns for Magento 2 - Magento Live UK
Key Insights into Development Design Patterns for Magento 2 - Magento Live UKKey Insights into Development Design Patterns for Magento 2 - Magento Live UK
Key Insights into Development Design Patterns for Magento 2 - Magento Live UK
 
Black Magic of Code Generation in Magento 2
Black Magic of Code Generation in Magento 2Black Magic of Code Generation in Magento 2
Black Magic of Code Generation in Magento 2
 
Clean Javascript
Clean JavascriptClean Javascript
Clean Javascript
 

Recently uploaded

₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...Diya Sharma
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Roomdivyansh0kumar0
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Servicegwenoracqe6
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607dollysharma2066
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)Damian Radcliffe
 
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersDamian Radcliffe
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024APNIC
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Servicesexy call girls service in goa
 
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.soniya singh
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 

Recently uploaded (20)

₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)
 
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
 
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 

Meet Magento DE 2016 - Kristof Ringleff - Growing up with Magento

  • 1. Kristof Ringleff / Director @ Fooman Growing Up With Magento Leveraging Magento 2 to improve your extensions
  • 4.
  • 5. Best practice today Required tomorrow Outdated the day after
  • 6. No substitute for continuously learning and improving
  • 7. Growing Up With Magento Leveraging Magento 2 to improve your extensions
  • 10. 1. Growing Up 2. Learning from Magento 3. Learning with the Community
  • 11. 1. Growing Up Invest in yourself
  • 15. 2. Learning from Magento Dependency Injection Service Contracts Unit Testing Integration Tests Functional Tests
  • 17. class SingletonExample { protected $singleton; public function __construct( Singleton $singleton ) { $this->singleton = $singleton; } } $objectManager->get('FoomanDiExamplesModelSingleton'); behind the scenes:
  • 18. class ModelExample { protected $model; public function __construct( Model $model ) { $this->model = $model; } } $objectManager->create('FoomanDiExamplesModelModel'); behind the scenes:
  • 19. class ModelExample { protected $model; public function __construct( Model $model ) { $this->model = $model; } } $objectManager->create('FoomanDiExamplesModelModel'); <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="FoomanDiExamplesModelModel" shared="false" /> </config> behind the scenes:
  • 20. Executive Summary Dependency Injection • Constructor based with Magento flavour • di.xml • Use Interfaces wherever possible • Don’t use the ObjectManager directly
  • 21.
  • 22. Create your Service Contracts with 2 Ingredients
  • 23. Magento 1.0 0 Unit Tests 0 Integration Tests 0 Functional Tests Magento 2.0 15K Unit Tests 3.5K Integration Tests 300 Functional Test Scenarios
  • 26. <?php namespace FoomanPrintOrderPdfControllerAdminhtmlOrder; /** * @magentoAppArea adminhtml */ class PrintActionTest extends MagentoTestFrameworkTestCaseAbstractBackendController { public function setUp() { $this->resource = 'Magento_Sales::sales_order'; $this->uri = 'backend/fooman_printorderpdf/order/print'; parent::setUp(); } }
  • 27.
  • 28. public function testAclHasAccess() { if ($this->uri === null) { $this->markTestIncomplete('AclHasAccess test is not complete'); } $this->dispatch($this->uri); $this->assertNotSame(403, $this->getResponse()->getHttpResponseCode()); $this->assertNotSame(404, $this->getResponse()->getHttpResponseCode()); } public function testAclNoAccess() { if ($this->resource === null) { $this->markTestIncomplete('Acl test is not complete'); } $this->_objectManager->get('MagentoFrameworkAclBuilder’)->getAcl() ->deny(null, $this->resource); $this->dispatch($this->uri); $this->assertSame(403, $this->getResponse()->getHttpResponseCode()); }
  • 29. public function testInvoiceNumberWithoutPrefix() { /** @var MagentoSalesApiDataOrderInterface $order */ $order = $this->objectManager->create('MagentoSalesApiDataOrderInterface') ->load('100000001', 'increment_id'); /** @var MagentoSalesApiInvoiceManagementInterface $invoiceMgmt */ $invoiceMgmt = $this->objectManager- >get('MagentoSalesApiInvoiceManagementInterface'); $invoice = $invoiceMgmt ->prepareInvoice($order); /** @var MagentoSalesApiInvoiceRepositoryInterface $invoiceRepo */ $invoiceRepo = $this->objectManager- >get('MagentoSalesApiInvoiceRepositoryInterface'); $invoiceRepo ->save($invoice); $this->assertEquals('100000001', $invoice->getIncrementId()); }
  • 30. /** * @magentoDataFixture Magento/Sales/_files/order.php */ public function testInvoiceNumberWithoutPrefix() { /** @var MagentoSalesApiDataOrderInterface $order */ $order = $this->objectManager->create('MagentoSalesApiDataOrderInterface') ->load('100000001', 'increment_id'); /** @var MagentoSalesApiInvoiceManagementInterface $invoiceMgmt */ $invoiceMgmt = $this->objectManager- >get('MagentoSalesApiInvoiceManagementInterface'); $invoice = $invoiceMgmt ->prepareInvoice($order); /** @var MagentoSalesApiInvoiceRepositoryInterface $invoiceRepo */ $invoiceRepo = $this->objectManager- >get('MagentoSalesApiInvoiceRepositoryInterface'); $invoiceRepo ->save($invoice); $this->assertEquals('100000001', $invoice->getIncrementId()); }
  • 33. <?php namespace FoomanGoogleAnalyticsPlusTestTestCase; use MagentoMtfTestCaseScenario; class CreateGaOrderTest extends Scenario { public function test() { $this->executeScenario(); } }
  • 34. <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/TestCase/etc/testcase.xsd"> <scenario name="CreateGaOrderTest" firstStep="setupConfiguration"> <step name="setupConfiguration" module="Magento_Config" next="createProducts"/> <step name="createProducts" module="Magento_Catalog" next="createTaxRule"/> <step name="createTaxRule" module="Magento_Tax" next="addProductsToTheCart"/> <step name="addProductsToTheCart" module="Magento_Checkout" next="estimateShippingAndTax"/> <step name="estimateShippingAndTax" module="Magento_Checkout" next="clickProceedToCheckout"/> <step name="clickProceedToCheckout" module="Magento_Checkout" next="createCustomer"/> <step name="createCustomer" module="Magento_Customer" next="selectCheckoutMethod"/> <step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress"/> <step name="fillShippingAddress" module="Magento_Checkout" next="fillShippingMethod"/> <step name="fillShippingMethod" module="Magento_Checkout" next="selectPaymentMethod"/> <step name="selectPaymentMethod" module="Magento_Checkout" next="fillBillingInformation"/> <step name="fillBillingInformation" module="Magento_Checkout" next="placeOrder"/> <step name="placeOrder" module="Magento_Checkout"/> </scenario> </config>
  • 35. <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/TestCase/etc/testcase.xsd"> <scenario name="CreateGaOrderTest" firstStep="setupConfiguration"> <step name="setupConfiguration" module="Magento_Config" next="createProducts"/> <step name="createProducts" module="Magento_Catalog" next="createTaxRule"/> <step name="createTaxRule" module="Magento_Tax" next="addProductsToTheCart"/> <step name="addProductsToTheCart" module="Magento_Checkout" next="estimateShippingAndTax"/> <step name="estimateShippingAndTax" module="Magento_Checkout" next="clickProceedToCheckout"/> <step name="clickProceedToCheckout" module="Magento_Checkout" next="createCustomer"/> <step name="createCustomer" module="Magento_Customer" next="selectCheckoutMethod"/> <step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress"/> <step name="fillShippingAddress" module="Magento_Checkout" next="fillShippingMethod"/> <step name="fillShippingMethod" module="Magento_Checkout" next="selectPaymentMethod"/> <step name="selectPaymentMethod" module="Magento_Checkout" next="fillBillingInformation"/> <step name="fillBillingInformation" module="Magento_Checkout" next="placeOrder"/> <step name="placeOrder" module="Magento_Checkout"/> </scenario> </config>
  • 36. <?xml version="1.0" encoding="utf-8"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="FoomanGoogleAnalyticsPlusTestTestCaseCreateGaOrderTest" summary="Create Order and check transaction tracking" ticketId=""> <variation name="CreateOrderTestTrackingEnabled" summary="Place an order"> <data name="products" xsi:type="string">catalogProductSimple::default</data> <data name="customer/dataset" xsi:type="string">default</data> <data name="checkoutMethod" xsi:type="string">guest</data> <data name="shippingAddress/dataset" xsi:type="string">UK_address</data> <data name="shipping/shippin99g_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_method" xsi:type="string">Fixed</data> <data name="prices" xsi:type="array"> <item name="grandTotal" xsi:type="string">565.00</item> </data> <data name="payment/method" xsi:type="string">checkmo</data> <data name="status" xsi:type="string">Pending</data> <data name="configData" xsi:type="string">google_universal_enabled</data> <constraint name="FoomanGoogleAnalyticsPlusTestConstraintAssertEcTracking" /> </variation> </testCase> </config>
  • 37. <?xml version="1.0" encoding="utf-8"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="FoomanGoogleAnalyticsPlusTestTestCaseCreateGaOrderTest" summary="Create Order and check transaction tracking" ticketId=""> <variation name="CreateOrderTestTrackingEnabled" summary="Place an order"> <data name="products" xsi:type="string">catalogProductSimple::default</data> <data name="customer/dataset" xsi:type="string">default</data> <data name="checkoutMethod" xsi:type="string">guest</data> <data name="shippingAddress/dataset" xsi:type="string">UK_address</data> <data name="shipping/shippin99g_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_method" xsi:type="string">Fixed</data> <data name="prices" xsi:type="array"> <item name="grandTotal" xsi:type="string">565.00</item> </data> <data name="payment/method" xsi:type="string">checkmo</data> <data name="status" xsi:type="string">Pending</data> <data name="configData" xsi:type="string">google_universal_enabled</data> <constraint name="FoomanGoogleAnalyticsPlusTestConstraintAssertEcTracking" /> </variation> </testCase> </config>
  • 38. <?php namespace FoomanGoogleAnalyticsPlusTestConstraint; use MagentoCheckoutTestPageCheckoutOnepageSuccess; class AssertEcTrackingIsPresent extends MagentoMtfConstraintAbstractConstraint { const GA_EC = "ga('ec:setAction', 'purchase'"; public function processAssert(CheckoutOnepageSuccess $checkoutOnepageSuccess) { PHPUnit_Framework_Assert::assertContains( self::GA_EC, $checkoutOnepageSuccess->getFoomanBody()->getGaScript(), 'Ecommerce Tracking is not present.' ); } }
  • 41. $order = $this->fixtureFactory->createByCode( 'orderInjectable', ['dataset' => 'default'] ); $order->persist(); $order = $this->fixtureFactory->createByCode( 'orderInjectable', ['dataset' => with_coupon'] ); $order->persist();
  • 42. $order = $this->fixtureFactory->createByCode( 'orderInjectable', ['dataset' => 'default'] ); $order->persist(); $order = $this->fixtureFactory->createByCode( 'orderInjectable', ['dataset' => with_coupon'] ); $order->persist(); $order = $this->fixtureFactory->createByCode( 'orderInjectable', ['dataset' => virtual_product'] ); $order->persist();
  • 43. 3. Learning with the Community Composer + Semantic Versioning PSR-X Get involved
  • 44. PHP is growing up too
  • 48. PSR-X Don’t be the IE of developers php-cs-fixer fix --level=psr2 .
  • 49. Best way to keep learning?
  • 53. 1. Growing Up Invest in yourself 2. Learning from Magento Dependency Injection Use and create your own Service Contracts Leverage Test Frameworks 3. Learning with the Community Composer + Semantic Versioning PSR-X Get involved