SlideShare a Scribd company logo
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

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 News
alertchair8725
 
Optimization in django orm
Optimization in django ormOptimization in django orm
Optimization in django orm
Denys 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 Chepurnyi
Meet Magento Spain
 
Pruebas unitarias con django
Pruebas unitarias con djangoPruebas unitarias con django
Pruebas unitarias con django
Tomás Henríquez
 
International News | World News
International News | World NewsInternational News | World News
International News | World News
joblessbeach6696
 
Technology and Science News - ABC News
Technology and Science News - ABC NewsTechnology and Science News - ABC News
Technology and Science News - ABC News
talloration5719
 
QA for PHP projects
QA for PHP projectsQA for PHP projects
QA for PHP projects
Michelangelo van Dam
 
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
eminentoomph4388
 
International News | World News
International News | World NewsInternational News | World News
International News | World News
wrathfulmedal3110
 
Effective Android Data Binding
Effective Android Data BindingEffective Android Data Binding
Effective Android Data Binding
Eric Maxwell
 
Modern Android Architecture
Modern Android ArchitectureModern Android Architecture
Modern Android Architecture
Eric 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 Tips
shortguidebook822
 
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
alertchair8725
 
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 Quinones
numberlesspasto93
 
Introduction to Zend Framework web services
Introduction to Zend Framework web servicesIntroduction to Zend Framework web services
Introduction to Zend Framework web services
Michelangelo van Dam
 
Optimizing Magento by Preloading Data
Optimizing Magento by Preloading DataOptimizing Magento by Preloading Data
Optimizing Magento by Preloading Data
Ivan 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
Data20161007
capegmail
 
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
Samuel ROZE
 

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
 
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
 

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 handout
CAMTIC
 
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
Kristof Ringleff
 
Língua port. ii sociolinguística
Língua port. ii   sociolinguísticaLíngua port. ii   sociolinguística
Língua port. ii sociolinguística
Anyellen 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 Meeting
CAMTIC
 
CAMTIC English Presentation (Enero, 2011)
CAMTIC English Presentation (Enero, 2011)CAMTIC English Presentation (Enero, 2011)
CAMTIC English Presentation (Enero, 2011)
CAMTIC
 
Bureau Klantzicht
Bureau KlantzichtBureau Klantzicht
Bureau Klantzicht
Joàn Harms 1200+
 
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 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
 

Similar to Growing up with Magento

Magento Performance Toolkit
Magento Performance ToolkitMagento Performance Toolkit
Magento Performance Toolkit
Sergii Shymko
 
Using of TDD practices for Magento
Using of TDD practices for MagentoUsing of TDD practices for Magento
Using of TDD practices for Magento
Ivan 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 4
Javier Eguiluz
 
Magento Indexes
Magento IndexesMagento Indexes
Magento Indexes
Ivan Chepurnyi
 
Magento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowMagento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request Flow
Vrann Tulika
 
Symfony 4 Workshop - Limenius
Symfony 4 Workshop - LimeniusSymfony 4 Workshop - Limenius
Symfony 4 Workshop - Limenius
Ignacio Martín
 
Clean Javascript
Clean JavascriptClean Javascript
Clean Javascript
Ryunosuke SATO
 
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
Hendy 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 patterns
Samuel 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 UK
Max Pronko
 
Curso Symfony - Clase 2
Curso Symfony - Clase 2Curso Symfony - Clase 2
Curso Symfony - Clase 2
Javier 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.docx
gilpinleeanna
 
Unit testing zend framework apps
Unit testing zend framework appsUnit testing zend framework apps
Unit testing zend framework apps
Michelangelo van Dam
 
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
Career 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
 
JavaScript Refactoring
JavaScript RefactoringJavaScript Refactoring
JavaScript Refactoring
Krzysztof Szafranek
 
Hacking Movable Type
Hacking Movable TypeHacking Movable Type
Hacking Movable Type
Stefano Rodighiero
 
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
Sergii Shymko
 

Similar to 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
 

Recently uploaded

Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
ShamsuddeenMuhammadA
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
QuickwayInfoSystems3
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Yara Milbes
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 

Recently uploaded (20)

Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 

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.