SlideShare ist ein Scribd-Unternehmen logo
1 von 58
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
Leveraging Magento 2 to improve your extensions
Growing Up with Magento
Guess the Accent Game
Guess the Accent Game
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());
}
Complete List of Annotations
@magentoAppArea
@magentoDataFixture
@magentoConfigFixture
@magentoAppIsolation
@magentoDataFixtureBeforeTransaction
@magentoDbIsolation
@magentoComponentsDir
@magentoCache
@magentoAdminConfigFixture
!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/shipping_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/shipping_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
"require": {
"magento/module-google-analytics": "~100.0.2"
}
My Version N+1
"require": {
"magento/module-google-analytics": "~100.0.2 | ~101.0.1"
}
PSR-2
Don’t be the IE of developers
php-cs-fixer fix --level=psr2 .
Best way to keep learning?
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
@foomanNZ
kristof@fooman.co.nz
or later via
Questions?
Legal
Copyright © 2016 Magento, Inc.; All Rights Reserved.
Magento® and its respective logos are trademarks, service marks, registered
trademarks, or registered service marks of Magento, Inc. and its affiliates. Other
trademarks or service marks contained in this presentation are the property of the
respective companies with which they are associated.
This presentation is for informational and discussion purposes only and should not
be construed as a commitment of Magento, Inc. or of any of its affiliates. While we
attempt to ensure the accuracy, completeness and adequacy of this presentation,
neither Magento, Inc. nor any of its affiliates are responsible for any errors or will
be liable for the use of, or reliance upon, this presentation or any of the information
contained in it. Unauthorized use, disclosure or dissemination of this information is
expressly prohibited.
Growing up with Magento

Weitere ähnliche Inhalte

Was ist angesagt?

Technology and Science News - ABC News
Technology and Science News - ABC NewsTechnology and Science News - ABC News
Technology and Science News - ABC Newsalertchair8725
 
Optimization in django orm
Optimization in django ormOptimization in django orm
Optimization in django ormDenys Levchenko
 
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
 
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
 
Modern Android Architecture
Modern Android ArchitectureModern Android Architecture
Modern Android ArchitectureEric Maxwell
 
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
 
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
 
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
 
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
 
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
 
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
 
Data20161007
Data20161007Data20161007
Data20161007capegmail
 
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
 

Was ist angesagt? (20)

Technology and Science News - ABC News
Technology and Science News - ABC NewsTechnology and Science News - ABC News
Technology and Science News - ABC News
 
Optimization in django orm
Optimization in django ormOptimization in django orm
Optimization in django orm
 
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
 
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
 
Technology and Science News - ABC News
Technology and Science News - ABC NewsTechnology and Science News - ABC News
Technology and Science News - ABC News
 
QA for PHP projects
QA for PHP projectsQA for PHP projects
QA for PHP projects
 
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
 
Modern Android Architecture
Modern Android ArchitectureModern Android Architecture
Modern Android Architecture
 
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
 
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
 
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
 
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
 
Introduction to Zend Framework web services
Introduction to Zend Framework web servicesIntroduction to Zend Framework web services
Introduction to Zend Framework web services
 
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)
 
Data20161007
Data20161007Data20161007
Data20161007
 
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
 

Andere mochten auch

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
 
Meet Magento DE 2016 - Kristof Ringleff - Growing up with Magento
Meet Magento DE 2016 - Kristof Ringleff - Growing up with MagentoMeet Magento DE 2016 - Kristof Ringleff - Growing up with Magento
Meet Magento DE 2016 - Kristof Ringleff - Growing up with MagentoKristof Ringleff
 
Língua port. ii sociolinguística
Língua port. ii   sociolinguísticaLíngua port. ii   sociolinguística
Língua port. ii sociolinguísticaAnyellen Mendanha
 
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
 
CAMTIC English Presentation (Enero, 2011)
CAMTIC English Presentation (Enero, 2011)CAMTIC English Presentation (Enero, 2011)
CAMTIC English Presentation (Enero, 2011)CAMTIC
 
Bureau Klantzicht @ www.bureauklantzicht.nl
Bureau Klantzicht @ www.bureauklantzicht.nlBureau Klantzicht @ www.bureauklantzicht.nl
Bureau Klantzicht @ www.bureauklantzicht.nlJoàn Harms 1200+
 

Andere mochten auch (18)

Kids Avoir1
Kids Avoir1Kids Avoir1
Kids Avoir1
 
Bureau Klantzicht Presentatie
Bureau Klantzicht PresentatieBureau Klantzicht Presentatie
Bureau Klantzicht Presentatie
 
Kids Avoir
Kids AvoirKids Avoir
Kids Avoir
 
Little-Bird
Little-BirdLittle-Bird
Little-Bird
 
Kids Avoir1
Kids Avoir1Kids Avoir1
Kids Avoir1
 
Kids Adj Ppt 1
Kids Adj Ppt 1Kids Adj Ppt 1
Kids Adj Ppt 1
 
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
 
Learnin\'
Learnin\'Learnin\'
Learnin\'
 
In The
In TheIn The
In The
 
Meet Magento DE 2016 - Kristof Ringleff - Growing up with Magento
Meet Magento DE 2016 - Kristof Ringleff - Growing up with MagentoMeet Magento DE 2016 - Kristof Ringleff - Growing up with Magento
Meet Magento DE 2016 - Kristof Ringleff - Growing up with Magento
 
Língua port. ii sociolinguística
Língua port. ii   sociolinguísticaLíngua port. ii   sociolinguística
Língua port. ii sociolinguística
 
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
 
CAMTIC English Presentation (Enero, 2011)
CAMTIC English Presentation (Enero, 2011)CAMTIC English Presentation (Enero, 2011)
CAMTIC English Presentation (Enero, 2011)
 
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
 

Ähnlich wie Growing up with Magento

Magento Performance Toolkit
Magento Performance ToolkitMagento Performance Toolkit
Magento Performance ToolkitSergii Shymko
 
Using of TDD practices for Magento
Using of TDD practices for MagentoUsing of TDD practices for Magento
Using of TDD practices for MagentoIvan Chepurnyi
 
Magento Dependency Injection
Magento Dependency InjectionMagento Dependency Injection
Magento Dependency InjectionAnton Kril
 
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
 
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
 
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
 
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
 
Curso Symfony - Clase 2
Curso Symfony - Clase 2Curso Symfony - Clase 2
Curso Symfony - Clase 2Javier Eguiluz
 
Magento Attributes - Fresh View
Magento Attributes - Fresh ViewMagento Attributes - Fresh View
Magento Attributes - Fresh ViewAlex Gotgelf
 
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
 
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
 
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
 

Ähnlich wie Growing up with Magento (20)

Magento Performance Toolkit
Magento Performance ToolkitMagento Performance Toolkit
Magento Performance Toolkit
 
Using of TDD practices for Magento
Using of TDD practices for MagentoUsing of TDD practices for Magento
Using of TDD practices for Magento
 
Magento Dependency Injection
Magento Dependency InjectionMagento Dependency Injection
Magento Dependency Injection
 
Curso Symfony - Clase 4
Curso Symfony - Clase 4Curso Symfony - Clase 4
Curso Symfony - Clase 4
 
Magento Indexes
Magento IndexesMagento Indexes
Magento Indexes
 
Magento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowMagento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request Flow
 
Symfony 4 Workshop - Limenius
Symfony 4 Workshop - LimeniusSymfony 4 Workshop - Limenius
Symfony 4 Workshop - Limenius
 
Clean Javascript
Clean JavascriptClean Javascript
Clean Javascript
 
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
 
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
 
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
 
Curso Symfony - Clase 2
Curso Symfony - Clase 2Curso Symfony - Clase 2
Curso Symfony - Clase 2
 
Magento Attributes - Fresh View
Magento Attributes - Fresh ViewMagento Attributes - Fresh View
Magento Attributes - Fresh View
 
Morgagebuildclasses.netbeans_automatic_buildMorgagebui.docx
Morgagebuildclasses.netbeans_automatic_buildMorgagebui.docxMorgagebuildclasses.netbeans_automatic_buildMorgagebui.docx
Morgagebuildclasses.netbeans_automatic_buildMorgagebui.docx
 
Unit testing zend framework apps
Unit testing zend framework appsUnit testing zend framework apps
Unit testing zend framework apps
 
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
 
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
 
JavaScript Refactoring
JavaScript RefactoringJavaScript Refactoring
JavaScript Refactoring
 
Hacking Movable Type
Hacking Movable TypeHacking Movable Type
Hacking Movable Type
 
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
 

Kürzlich hochgeladen

MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 

Kürzlich hochgeladen (20)

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 

Growing up with Magento

  • 1.
  • 2. Growing Up With Magento Leveraging Magento 2 to improve your extensions
  • 5.
  • 6. Best practice today Required tomorrow Outdated the day after
  • 7. No substitute for continuously learning and improving
  • 8. Leveraging Magento 2 to improve your extensions Growing Up with Magento
  • 10. Guess the Accent Game 2004
  • 11.
  • 12. 1. Growing Up 2. Learning from Magento 3. Learning with the Community
  • 13. 1. Growing Up Invest in yourself
  • 17. 2. Learning from Magento Dependency Injection Service Contracts Unit Testing Integration Tests Functional Tests
  • 19. class SingletonExample { protected $singleton; public function __construct( Singleton $singleton ) { $this->singleton = $singleton; } } $objectManager->get('FoomanDiExamplesModelSingleton'); behind the scenes:
  • 20. class ModelExample { protected $model; public function __construct( Model $model ) { $this->model = $model; } } $objectManager->create('FoomanDiExamplesModelModel'); behind the scenes:
  • 21. 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:
  • 22. Executive Summary Dependency Injection • Constructor based with Magento flavour • di.xml • Use Interfaces wherever possible • Don’t use the ObjectManager directly
  • 23. Create your Service Contracts with 2 Ingredients
  • 24.
  • 25. 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
  • 28. <?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(); } }
  • 29.
  • 30. 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()); }
  • 31. 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()); }
  • 32. /** * @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. Complete List of Annotations @magentoAppArea @magentoDataFixture @magentoConfigFixture @magentoAppIsolation @magentoDataFixtureBeforeTransaction @magentoDbIsolation @magentoComponentsDir @magentoCache @magentoAdminConfigFixture
  • 36. <?php namespace FoomanGoogleAnalyticsPlusTestTestCase; use MagentoMtfTestCaseScenario; class CreateGaOrderTest extends Scenario { public function test() { $this->executeScenario(); } }
  • 37. <?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>
  • 38. <?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>
  • 39. <?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/shipping_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>
  • 40. <?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/shipping_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>
  • 41. <?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.' ); } }
  • 44. $order = $this->fixtureFactory->createByCode( 'orderInjectable', ['dataset' => 'default'] ); $order->persist(); $order = $this->fixtureFactory->createByCode( 'orderInjectable', ['dataset' => with_coupon'] ); $order->persist();
  • 45. $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();
  • 46. 3. Learning with the Community Composer + Semantic Versioning PSR-X Get involved
  • 47. PHP is growing up too
  • 49. My Version N "require": { "magento/module-google-analytics": "~100.0.2" }
  • 50. My Version N+1 "require": { "magento/module-google-analytics": "~100.0.2 | ~101.0.1" }
  • 51. PSR-2 Don’t be the IE of developers php-cs-fixer fix --level=psr2 .
  • 52. Best way to keep learning?
  • 55. 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
  • 57. Legal Copyright © 2016 Magento, Inc.; All Rights Reserved. Magento® and its respective logos are trademarks, service marks, registered trademarks, or registered service marks of Magento, Inc. and its affiliates. Other trademarks or service marks contained in this presentation are the property of the respective companies with which they are associated. This presentation is for informational and discussion purposes only and should not be construed as a commitment of Magento, Inc. or of any of its affiliates. While we attempt to ensure the accuracy, completeness and adequacy of this presentation, neither Magento, Inc. nor any of its affiliates are responsible for any errors or will be liable for the use of, or reliance upon, this presentation or any of the information contained in it. Unauthorized use, disclosure or dissemination of this information is expressly prohibited.