SlideShare ist ein Scribd-Unternehmen logo
1 von 98
Downloaden Sie, um offline zu lesen
GETTING YOUR HANDS DIRTY
TESTING
MAGENTO 2
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
ME
Freelance Developer & Trainer
https://github.com/vinai
https://twitter.com/vinaikopp
Dev since 1998
PHP WebDev since PHP3 (1999)
Magento since 2008-01-01
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
TESTING
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
WHO IS DOING IT?
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
WHAT TOOL?
> PHPUnit?
> Behat && PHPSpec?
> Selenium?
> Codeception?
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
BUZZWORD
BINGO
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
BUZZWORD I:
UNIT TEST
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
$ vendor/bin/phpunit -c "dev/tests/unit/phpunit.xml.dist"
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
$ alias unit-test="$(pwd)/vendor/bin/phpunit
-c $(pwd)/dev/tests/unit/phpunit.xml.dist"
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
$ unit-test
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
$ unit-test "app/code/My/Module/Test/Unit"
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
TRY IT
vendor/bin/phpunit 
-c "dev/tests/unit/phpunit.xml.dist" 
vendor/magento/module-catalog/Test/Unit/Block
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
BUZZWORD II:
INTEGRATION
TEST
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
WHAT IS THE
DIFFERENCE?
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
REAL OBJECTS INTERACT
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
INTEGRATION TESTS NEED THE
RUNTIME ENVIRONMENT
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
A failing unit test tells me
exactly where my code is broken.
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
A failing integration test only
tells me that something is broken.
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
Separate DB
dev/tests/integration/etc/install-config-mysql.php.dist
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
$ vendor/bin/phpunit -c dev/tests/integration/phpunit.xml
Could not read "dev/tests/integration/phpunit.xml".
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
$ cd dev/tests/integration
$ ../../../vendor/bin/phpunit
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
Every run gets it's own
etc, pub and var dirs
dev/tests/integration/tmp/
sandbox-0-b79c13eb842cf3211459b11c775bfbde/
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
BUZZWORD III:
TDD
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
WHAT IS TDD?
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
THE 3 RULES
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
I. No production code without
a failing unit test
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
II. Once there is a failing unit test,
stop and make it pass
by writing production code
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
III. Once the test passes,
stop writing production code
until you have a failing unit test again
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
TDD FOR MAGENTO 2
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
NO DIFFERENCE
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
</TDD>
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
To learn more about TDD,
check out the Clean Coders
Videos from Robert C. Martin
http://cleancoders.com
(or do a training)
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
INTEGRATION TESTS
FOR MAGENTO 2
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
VERY SPECIFIC
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
PLATFORM KNOWLEDGE
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
Magento 2 Testing Framework
dev/tests/integration/framework
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
Test Framework ObjectManager
MagentoTestFrameworkObjectManager::getInstance()
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
Dependencies
$configReader = $objectManager->create(Reader::class);
$deploymentConfig = $objectManager->create(
DeploymentConfig::class,
['reader' => $configReader]
);
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
BUZZWORD IV
FIXTURES
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
Fix the system into a known state
before a test is executed.
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
Simple PHP Scripts
Relative to
dev/tests/integration/testsuite
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
/**
* @magentoDataFixture Magento/Sales/_files/order.php
* @magentoDataFixture Magento/Customer/_files/customer.php
*/
public function testSomethingWithAnOrderAndACustomer()
{
// ...
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
CONFIG FIXTURES
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
Store Scope
/**
* @magentoConfigFixture current_store catalog/price/scope 1
*/
public function testDoesSomeoneReadThisHelpMeLetMeOut()
{
// ...
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
Global Scope
/**
* @magentoConfigFixture currency/options/allow USD
*/
public function testHowMashAndPieTastes()
{
// ...
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
BUZZWORD V
TEST ISOLATION
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
FRESH INSTALL
FOR EACH TEST RUN
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
dev/tests/integration/phpunit.xml.dist
<phpunit>
...
<php>
...
<const name="TESTS_CLEANUP" value="enabled"/>
...
</php>
...
</phpunit>
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
TESTS_CLEANUP
== disabled
SPEEDS THINGS UP
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
TESTS_CLEANUP
== disabled
MANUAL CLEANUP REQUIRED
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
integration/tmp/sandbox-*
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
DATABASE ISOLATION
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
TRANSACTIONS
OR
ROLLBACK SCRIPTS
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
TRANSACTIONS
/**
* @magentoDbIsolation enabled
*/
public function testWithoutSideEffects
{
// ...
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
TRANSACTIONS
/**
* @magentoDataFixture Magento/Foo/_files/bar.php
*/
public function testTheFixtureIsAppliedWithinATransaction
{
// ...
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
ROLLBACK SCRIPTS
/**
* @magentoDataFixture Magento/Customer/_files/customer.php
* @magentoDbIsolation disabled
*/
public function testTransactionalCode()
{
// ...
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
Before Test
include 'Magento/Customer/_files/customer.php';
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
After Test
include 'Magento/Customer/_files/customer_rollback.php';
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
APPLICATION ISOLATION
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
REINSTANTIATE
ALMOST EVERYTHING
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
RESET MAGENTO AFTER TEST
/**
* @magentoAppIsolation enabled
*/
public function testTestWithSingletons()
{
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
Controller Tests: Automatic reset
class FooBarIndexActionTest extends
MagentoTestFrameworkTestCaseAbstractController
{
public function testTheLayoutIsRendered()
{
$this->dispatch('foo/bar/index');
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
REMEMBER
THIS
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
ISOLATE
YOUR TESTS
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
AND ALL WILL BE
GOOD
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
[breathing pause]
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
APPLICATION AREA
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
APP AREAS
global
frontend
adminhtml
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
/**
* @magentoAppArea frontend
*/
class AddressesTest extends PHPUnit_Framework_TestCase
{
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
MORE AREAS
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
webapi_rest
webapi_soap
cron
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
MagentoTestFrameworkAppState
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
public function testPluginInWebapiRestScope()
{
$class = MagentoTestFrameworkAppState::class;
$appAreaState = $this->objectManager->get($class);
$appAreaState->setAreaCode('webapi_rest');
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
protected function tearDown()
{
// ...
$appAreaState->setAreaCode(null);
}
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
ACTION
[CONTROLLER]
TESTS
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
FRONTEND
MagentoTestFrameworkTestCase
AbstractController
ADMINHTML
MagentoTestFrameworkTestCase
AbstractBackendController
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
EXAMPLE!
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
Event Observer for:
sales_order_place_after
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
I. TESTING THE
CONFIGURATION
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
public function testTheModuleRegistersASalesOrderPlaceAfterObserver()
{
$class = MagentoFrameworkEventConfig::class;
$eventConfig = ObjectManager::getInstance()->create($class);
$observers = $eventConfig->getObservers('sales_order_place_after');
$this->assertArrayHasKey('meetup_observer', $observers);
$expectedClass = MeetupObserverObserverSalesOrderPlaceAfter::class;
$this->assertSame($expectedClass, $observers['meetup_observer']['instance']);
$this->assertFalse($observers['meetup_observer']['shared']);
}
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
1/2) Get the config in array format
$class = MagentoFrameworkEventConfig::class;
$eventConfig = ObjectManager::getInstance()->create($class);
$event = 'sales_order_place_after';
$observers = $eventConfig->getObservers($event);
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
2/2) Assert config values
$this->assertArrayHasKey('meetup_observer', $observers);
$this->assertSame(
SalesOrderPlaceAfter::class,
$observers['meetup_observer']['instance']
);
$this->assertFalse($observers['meetup_observer']['shared']);
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
II. TESTING THE OBSERVER
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
O_0(NOTHING TO TEST)
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
III. INTEGRATION TEST
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
Our observer has no side effects.
We have to improvise...
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
/**
* @magentoDataFixture Magento/Sales/_files/order.php
*/
public function testSalesOrderPlaceAfterObserverIsCalled()
{
$this->injectMockObserverWithExpectation();
$order = $this->getOrderFixture();
$this->objectManager
->create(OrderManagementInterface::class)
->place($order);
}
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
public function injectMockObserverWithExpectation()
{
$mockObserver = $this->getMock(SalesOrderPlaceAfter::class);
$mockObserver->expects($this->once())->method('execute');
$this->registerObserverTestDouble($mockObserver);
}
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
private function registerObserverTestDouble($mockObserver)
{
$class = MagentoFrameworkEventConfigData::class;
$eventConfigData = $this->objectManager->get($class);
$event = 'sales_order_place_after';
$name = 'meetup_observer';
$eventConfigData->merge(
[$event => [$name => ['shared' => true]]]
);
// ...
}
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
private function registerObserverTestDouble($mockObserver)
{
// ...
$this->objectManager->addSharedInstance(
$mockObserver,
SalesOrderPlaceAfter::class
);
}
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
/**
* @magentoDataFixture Magento/Sales/_files/order.php
*/
public function testSalesOrderPlaceAfterObserverIsCalled()
{
// ...
$order = $this->getOrderFixture();
// ...
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
private function getOrderFixture()
{
$class = OrderRepositoryInterface::class;
$orderRepository = $this->objectManager->create($class);
$criteria = $this->objectManager
->create(SearchCriteriaBuilder::class)
->addFilter('increment_id', '100000001')
->create();
$result = $orderRepository->getList($criteria);
return array_values($result->getItems())[0];
}
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
/**
* @magentoDataFixture Magento/Sales/_files/order.php
*/
public function testSalesOrderPlaceAfterObserverIsCalled()
{
$this->injectMockObserverWithExpectation();
$order = $this->getOrderFixture();
$this->objectManager
->create(OrderManagementInterface::class)
->place($order);
}
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
GO FORTH
AND TESTALL THINGS!
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
ONE MORE THING...
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
MAGE2KATAS
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
MAGE2KATAS
> Screencast Series
> Examples
> Code Katas
mage2katas.com
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
THANK YOU <3
Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp

Weitere ähnliche Inhalte

Andere mochten auch

Max Yekaterynenko: Magento 2 overview
Max Yekaterynenko: Magento 2 overviewMax Yekaterynenko: Magento 2 overview
Max Yekaterynenko: Magento 2 overviewMeet Magento Italy
 
Magento 2 overview. Alan Kent
Magento 2 overview. Alan Kent Magento 2 overview. Alan Kent
Magento 2 overview. Alan Kent MeetMagentoNY2014
 
Sergii Shymko: Magento 2: Composer for Extensions Distribution
Sergii Shymko: Magento 2: Composer for Extensions DistributionSergii Shymko: Magento 2: Composer for Extensions Distribution
Sergii Shymko: Magento 2: Composer for Extensions DistributionMeet Magento Italy
 
Magento 2 looks like.
Magento 2 looks like.Magento 2 looks like.
Magento 2 looks like.Magestore
 
Sergii Shymko - Code migration tool for upgrade to Magento 2
Sergii Shymko - Code migration tool for upgrade to Magento 2Sergii Shymko - Code migration tool for upgrade to Magento 2
Sergii Shymko - Code migration tool for upgrade to Magento 2Meet Magento Italy
 
Magento 2 Design Patterns
Magento 2 Design PatternsMagento 2 Design Patterns
Magento 2 Design PatternsMax Pronko
 
Fundamentals of Extending Magento 2 - php[world] 2015
Fundamentals of Extending Magento 2 - php[world] 2015Fundamentals of Extending Magento 2 - php[world] 2015
Fundamentals of Extending Magento 2 - php[world] 2015David Alger
 
Magento 2 Seminar - Daniel Genis - Magento 2 benchmarks
Magento 2 Seminar - Daniel Genis - Magento 2 benchmarksMagento 2 Seminar - Daniel Genis - Magento 2 benchmarks
Magento 2 Seminar - Daniel Genis - Magento 2 benchmarksYireo
 
Imagine recap-devhub
Imagine recap-devhubImagine recap-devhub
Imagine recap-devhubMagento Dev
 
How to create theme in Magento 2 - Part 2
How to create theme in Magento 2 - Part 2How to create theme in Magento 2 - Part 2
How to create theme in Magento 2 - Part 2Magestore
 
Meet Magento Belarus - Magento2: What to expect and when? - Elena Leonova
Meet Magento Belarus -  Magento2: What to expect and when? - Elena LeonovaMeet Magento Belarus -  Magento2: What to expect and when? - Elena Leonova
Meet Magento Belarus - Magento2: What to expect and when? - Elena LeonovaElena Leonova
 
Oleh Kobchenko - Configure Magento 2 to get maximum performance
Oleh Kobchenko - Configure Magento 2 to get maximum performanceOleh Kobchenko - Configure Magento 2 to get maximum performance
Oleh Kobchenko - Configure Magento 2 to get maximum performanceMeet Magento Italy
 
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015Joshua Warren
 
How To Create Theme in Magento 2 - Part 1
How To Create Theme in Magento 2 - Part 1How To Create Theme in Magento 2 - Part 1
How To Create Theme in Magento 2 - Part 1Magestore
 

Andere mochten auch (15)

Max Yekaterynenko: Magento 2 overview
Max Yekaterynenko: Magento 2 overviewMax Yekaterynenko: Magento 2 overview
Max Yekaterynenko: Magento 2 overview
 
Magento 2 overview. Alan Kent
Magento 2 overview. Alan Kent Magento 2 overview. Alan Kent
Magento 2 overview. Alan Kent
 
Sergii Shymko: Magento 2: Composer for Extensions Distribution
Sergii Shymko: Magento 2: Composer for Extensions DistributionSergii Shymko: Magento 2: Composer for Extensions Distribution
Sergii Shymko: Magento 2: Composer for Extensions Distribution
 
Magento 2 looks like.
Magento 2 looks like.Magento 2 looks like.
Magento 2 looks like.
 
Sergii Shymko - Code migration tool for upgrade to Magento 2
Sergii Shymko - Code migration tool for upgrade to Magento 2Sergii Shymko - Code migration tool for upgrade to Magento 2
Sergii Shymko - Code migration tool for upgrade to Magento 2
 
Magento 2 Design Patterns
Magento 2 Design PatternsMagento 2 Design Patterns
Magento 2 Design Patterns
 
Fundamentals of Extending Magento 2 - php[world] 2015
Fundamentals of Extending Magento 2 - php[world] 2015Fundamentals of Extending Magento 2 - php[world] 2015
Fundamentals of Extending Magento 2 - php[world] 2015
 
Magento 2 Seminar - Daniel Genis - Magento 2 benchmarks
Magento 2 Seminar - Daniel Genis - Magento 2 benchmarksMagento 2 Seminar - Daniel Genis - Magento 2 benchmarks
Magento 2 Seminar - Daniel Genis - Magento 2 benchmarks
 
Imagine recap-devhub
Imagine recap-devhubImagine recap-devhub
Imagine recap-devhub
 
How to create theme in Magento 2 - Part 2
How to create theme in Magento 2 - Part 2How to create theme in Magento 2 - Part 2
How to create theme in Magento 2 - Part 2
 
Meet Magento Belarus - Magento2: What to expect and when? - Elena Leonova
Meet Magento Belarus -  Magento2: What to expect and when? - Elena LeonovaMeet Magento Belarus -  Magento2: What to expect and when? - Elena Leonova
Meet Magento Belarus - Magento2: What to expect and when? - Elena Leonova
 
Outlook on Magento 2
Outlook on Magento 2Outlook on Magento 2
Outlook on Magento 2
 
Oleh Kobchenko - Configure Magento 2 to get maximum performance
Oleh Kobchenko - Configure Magento 2 to get maximum performanceOleh Kobchenko - Configure Magento 2 to get maximum performance
Oleh Kobchenko - Configure Magento 2 to get maximum performance
 
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015
 
How To Create Theme in Magento 2 - Part 1
How To Create Theme in Magento 2 - Part 1How To Create Theme in Magento 2 - Part 1
How To Create Theme in Magento 2 - Part 1
 

Ähnlich wie Getting your Hands Dirty Testing Magento 2 (at London Meetup)

Writing Testable Code (for Magento 1 and 2) 2016 Romaina
Writing Testable Code (for Magento 1 and 2)  2016 RomainaWriting Testable Code (for Magento 1 and 2)  2016 Romaina
Writing Testable Code (for Magento 1 and 2) 2016 Romainavinaikopp
 
Testing Magento 2
Testing Magento 2Testing Magento 2
Testing Magento 2vinaikopp
 
Magento 2 TDD Code Kata Intro
Magento 2 TDD Code Kata IntroMagento 2 TDD Code Kata Intro
Magento 2 TDD Code Kata Introvinaikopp
 
Writing testable Code (MageTitans Mini 2016)
Writing testable Code (MageTitans Mini 2016)Writing testable Code (MageTitans Mini 2016)
Writing testable Code (MageTitans Mini 2016)vinaikopp
 
Vinai Kopp - FPC Hole punching in Magento 2
Vinai Kopp - FPC Hole punching in Magento 2Vinai Kopp - FPC Hole punching in Magento 2
Vinai Kopp - FPC Hole punching in Magento 2Meet Magento Italy
 
Vinai Kopp - How i develop M2 modules
Vinai Kopp - How i develop M2 modules Vinai Kopp - How i develop M2 modules
Vinai Kopp - How i develop M2 modules Meet Magento Italy
 
Magento 2 TDD Code Kata
Magento 2 TDD Code KataMagento 2 TDD Code Kata
Magento 2 TDD Code Katavinaikopp
 
Awesome Architectures in Magento 2.3 - MM19PL
Awesome Architectures in Magento 2.3 - MM19PLAwesome Architectures in Magento 2.3 - MM19PL
Awesome Architectures in Magento 2.3 - MM19PLRiccardo Tempesta
 
Palestra "Ionic Framework 2 - O que vem por aí?" TDC 2016
Palestra "Ionic Framework 2 - O que vem por aí?" TDC 2016Palestra "Ionic Framework 2 - O que vem por aí?" TDC 2016
Palestra "Ionic Framework 2 - O que vem por aí?" TDC 2016Tatiane Aguirres Nogueira
 
Contribution Day Guide - MM19JP
Contribution Day Guide - MM19JPContribution Day Guide - MM19JP
Contribution Day Guide - MM19JPOleksii Korshenko
 
2020 [pweb] 13 typescript
2020 [pweb] 13 typescript2020 [pweb] 13 typescript
2020 [pweb] 13 typescriptVICTOR JATOBÁ
 
Contribution day guide. MM19ES 2019
Contribution day guide. MM19ES 2019Contribution day guide. MM19ES 2019
Contribution day guide. MM19ES 2019Oleksii Korshenko
 
Tools out of the box with Magento 2 in PHPSTORM
Tools out of the box with Magento 2 in PHPSTORMTools out of the box with Magento 2 in PHPSTORM
Tools out of the box with Magento 2 in PHPSTORMAndra Elena Lungu
 
28. Magento Meetup Austria: Magento News
28. Magento Meetup Austria: Magento News28. Magento Meetup Austria: Magento News
28. Magento Meetup Austria: Magento NewsMagento Meetup Austria
 
Magento done right - PHP UK 2016
Magento done right  - PHP UK 2016Magento done right  - PHP UK 2016
Magento done right - PHP UK 2016Ciaran Rooney
 
SOS UiComponents
SOS UiComponentsSOS UiComponents
SOS UiComponentsvinaikopp
 
RobotFramework Meetup at Thailand #2
RobotFramework Meetup at Thailand #2RobotFramework Meetup at Thailand #2
RobotFramework Meetup at Thailand #2Somkiat Puisungnoen
 
Learnings PIM introduction - Magento Meetup Wien - may 2016
Learnings PIM introduction - Magento Meetup Wien - may 2016Learnings PIM introduction - Magento Meetup Wien - may 2016
Learnings PIM introduction - Magento Meetup Wien - may 2016Hartwig Brandl
 

Ähnlich wie Getting your Hands Dirty Testing Magento 2 (at London Meetup) (20)

Writing Testable Code (for Magento 1 and 2) 2016 Romaina
Writing Testable Code (for Magento 1 and 2)  2016 RomainaWriting Testable Code (for Magento 1 and 2)  2016 Romaina
Writing Testable Code (for Magento 1 and 2) 2016 Romaina
 
Testing Magento 2
Testing Magento 2Testing Magento 2
Testing Magento 2
 
Magento 2 TDD Code Kata Intro
Magento 2 TDD Code Kata IntroMagento 2 TDD Code Kata Intro
Magento 2 TDD Code Kata Intro
 
Writing testable Code (MageTitans Mini 2016)
Writing testable Code (MageTitans Mini 2016)Writing testable Code (MageTitans Mini 2016)
Writing testable Code (MageTitans Mini 2016)
 
Vinai Kopp - FPC Hole punching in Magento 2
Vinai Kopp - FPC Hole punching in Magento 2Vinai Kopp - FPC Hole punching in Magento 2
Vinai Kopp - FPC Hole punching in Magento 2
 
Vinai Kopp - How i develop M2 modules
Vinai Kopp - How i develop M2 modules Vinai Kopp - How i develop M2 modules
Vinai Kopp - How i develop M2 modules
 
Magento 2 TDD Code Kata
Magento 2 TDD Code KataMagento 2 TDD Code Kata
Magento 2 TDD Code Kata
 
Awesome Architectures in Magento 2.3 - MM19PL
Awesome Architectures in Magento 2.3 - MM19PLAwesome Architectures in Magento 2.3 - MM19PL
Awesome Architectures in Magento 2.3 - MM19PL
 
Palestra "Ionic Framework 2 - O que vem por aí?" TDC 2016
Palestra "Ionic Framework 2 - O que vem por aí?" TDC 2016Palestra "Ionic Framework 2 - O que vem por aí?" TDC 2016
Palestra "Ionic Framework 2 - O que vem por aí?" TDC 2016
 
Contribution Day Guide - MM19JP
Contribution Day Guide - MM19JPContribution Day Guide - MM19JP
Contribution Day Guide - MM19JP
 
2020 [pweb] 13 typescript
2020 [pweb] 13 typescript2020 [pweb] 13 typescript
2020 [pweb] 13 typescript
 
GraphQL in Magento 2
GraphQL in Magento 2GraphQL in Magento 2
GraphQL in Magento 2
 
Contribution day guide. MM19ES 2019
Contribution day guide. MM19ES 2019Contribution day guide. MM19ES 2019
Contribution day guide. MM19ES 2019
 
Ionic 2 - O que mudou?
Ionic 2 - O que mudou?Ionic 2 - O que mudou?
Ionic 2 - O que mudou?
 
Tools out of the box with Magento 2 in PHPSTORM
Tools out of the box with Magento 2 in PHPSTORMTools out of the box with Magento 2 in PHPSTORM
Tools out of the box with Magento 2 in PHPSTORM
 
28. Magento Meetup Austria: Magento News
28. Magento Meetup Austria: Magento News28. Magento Meetup Austria: Magento News
28. Magento Meetup Austria: Magento News
 
Magento done right - PHP UK 2016
Magento done right  - PHP UK 2016Magento done right  - PHP UK 2016
Magento done right - PHP UK 2016
 
SOS UiComponents
SOS UiComponentsSOS UiComponents
SOS UiComponents
 
RobotFramework Meetup at Thailand #2
RobotFramework Meetup at Thailand #2RobotFramework Meetup at Thailand #2
RobotFramework Meetup at Thailand #2
 
Learnings PIM introduction - Magento Meetup Wien - may 2016
Learnings PIM introduction - Magento Meetup Wien - may 2016Learnings PIM introduction - Magento Meetup Wien - may 2016
Learnings PIM introduction - Magento Meetup Wien - may 2016
 

Mehr von vinaikopp

Building Mage-OS - MageTitans 2023
Building Mage-OS - MageTitans 2023Building Mage-OS - MageTitans 2023
Building Mage-OS - MageTitans 2023vinaikopp
 
Hyvä: Compatibility Modules
Hyvä: Compatibility ModulesHyvä: Compatibility Modules
Hyvä: Compatibility Modulesvinaikopp
 
Hyvä from a developer perspective
Hyvä from a developer perspectiveHyvä from a developer perspective
Hyvä from a developer perspectivevinaikopp
 
Property Based Testing in PHP
Property Based Testing in PHPProperty Based Testing in PHP
Property Based Testing in PHPvinaikopp
 
Property based testing - MageTestFest 2019
Property based testing - MageTestFest 2019Property based testing - MageTestFest 2019
Property based testing - MageTestFest 2019vinaikopp
 
Becoming Certified - MageTitansMCR 2018
Becoming Certified - MageTitansMCR 2018Becoming Certified - MageTitansMCR 2018
Becoming Certified - MageTitansMCR 2018vinaikopp
 
ClojureScript in Magento 2 - PHPUGMRN
ClojureScript in Magento 2 - PHPUGMRNClojureScript in Magento 2 - PHPUGMRN
ClojureScript in Magento 2 - PHPUGMRNvinaikopp
 
ClojureScript in Magento 2 - MageTitansMCR 2017
ClojureScript in Magento 2 - MageTitansMCR 2017ClojureScript in Magento 2 - MageTitansMCR 2017
ClojureScript in Magento 2 - MageTitansMCR 2017vinaikopp
 
Lizards & Pumpkins Catalog Replacement at mm17de
Lizards & Pumpkins Catalog Replacement at mm17deLizards & Pumpkins Catalog Replacement at mm17de
Lizards & Pumpkins Catalog Replacement at mm17devinaikopp
 
Stories from the other side
Stories from the other sideStories from the other side
Stories from the other sidevinaikopp
 
Getting your hands dirty testing Magento 2 (at MageTitansIT)
Getting your hands dirty testing Magento 2 (at MageTitansIT)Getting your hands dirty testing Magento 2 (at MageTitansIT)
Getting your hands dirty testing Magento 2 (at MageTitansIT)vinaikopp
 
Architecture in-the-small-slides
Architecture in-the-small-slidesArchitecture in-the-small-slides
Architecture in-the-small-slidesvinaikopp
 
Modern Module Architecture
Modern Module ArchitectureModern Module Architecture
Modern Module Architecturevinaikopp
 
The beautiful Magento module - MageTitans 2014
The beautiful Magento module - MageTitans 2014The beautiful Magento module - MageTitans 2014
The beautiful Magento module - MageTitans 2014vinaikopp
 

Mehr von vinaikopp (14)

Building Mage-OS - MageTitans 2023
Building Mage-OS - MageTitans 2023Building Mage-OS - MageTitans 2023
Building Mage-OS - MageTitans 2023
 
Hyvä: Compatibility Modules
Hyvä: Compatibility ModulesHyvä: Compatibility Modules
Hyvä: Compatibility Modules
 
Hyvä from a developer perspective
Hyvä from a developer perspectiveHyvä from a developer perspective
Hyvä from a developer perspective
 
Property Based Testing in PHP
Property Based Testing in PHPProperty Based Testing in PHP
Property Based Testing in PHP
 
Property based testing - MageTestFest 2019
Property based testing - MageTestFest 2019Property based testing - MageTestFest 2019
Property based testing - MageTestFest 2019
 
Becoming Certified - MageTitansMCR 2018
Becoming Certified - MageTitansMCR 2018Becoming Certified - MageTitansMCR 2018
Becoming Certified - MageTitansMCR 2018
 
ClojureScript in Magento 2 - PHPUGMRN
ClojureScript in Magento 2 - PHPUGMRNClojureScript in Magento 2 - PHPUGMRN
ClojureScript in Magento 2 - PHPUGMRN
 
ClojureScript in Magento 2 - MageTitansMCR 2017
ClojureScript in Magento 2 - MageTitansMCR 2017ClojureScript in Magento 2 - MageTitansMCR 2017
ClojureScript in Magento 2 - MageTitansMCR 2017
 
Lizards & Pumpkins Catalog Replacement at mm17de
Lizards & Pumpkins Catalog Replacement at mm17deLizards & Pumpkins Catalog Replacement at mm17de
Lizards & Pumpkins Catalog Replacement at mm17de
 
Stories from the other side
Stories from the other sideStories from the other side
Stories from the other side
 
Getting your hands dirty testing Magento 2 (at MageTitansIT)
Getting your hands dirty testing Magento 2 (at MageTitansIT)Getting your hands dirty testing Magento 2 (at MageTitansIT)
Getting your hands dirty testing Magento 2 (at MageTitansIT)
 
Architecture in-the-small-slides
Architecture in-the-small-slidesArchitecture in-the-small-slides
Architecture in-the-small-slides
 
Modern Module Architecture
Modern Module ArchitectureModern Module Architecture
Modern Module Architecture
 
The beautiful Magento module - MageTitans 2014
The beautiful Magento module - MageTitans 2014The beautiful Magento module - MageTitans 2014
The beautiful Magento module - MageTitans 2014
 

Kürzlich hochgeladen

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
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
%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
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
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
 
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
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
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
 
%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
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 

Kürzlich hochgeladen (20)

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...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%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
 
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...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
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...
 
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
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
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
 
%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
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 

Getting your Hands Dirty Testing Magento 2 (at London Meetup)

  • 1. GETTING YOUR HANDS DIRTY TESTING MAGENTO 2 Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 2. ME Freelance Developer & Trainer https://github.com/vinai https://twitter.com/vinaikopp Dev since 1998 PHP WebDev since PHP3 (1999) Magento since 2008-01-01 Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 3. TESTING Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 4. WHO IS DOING IT? Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 5. WHAT TOOL? > PHPUnit? > Behat && PHPSpec? > Selenium? > Codeception? Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 6. BUZZWORD BINGO Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 7. BUZZWORD I: UNIT TEST Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 8. $ vendor/bin/phpunit -c "dev/tests/unit/phpunit.xml.dist" Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 9. $ alias unit-test="$(pwd)/vendor/bin/phpunit -c $(pwd)/dev/tests/unit/phpunit.xml.dist" Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 10. $ unit-test Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 11. $ unit-test "app/code/My/Module/Test/Unit" Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 12. TRY IT vendor/bin/phpunit -c "dev/tests/unit/phpunit.xml.dist" vendor/magento/module-catalog/Test/Unit/Block Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 13. BUZZWORD II: INTEGRATION TEST Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 14. WHAT IS THE DIFFERENCE? Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 15. REAL OBJECTS INTERACT Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 16. INTEGRATION TESTS NEED THE RUNTIME ENVIRONMENT Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 17. A failing unit test tells me exactly where my code is broken. Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 18. A failing integration test only tells me that something is broken. Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 19. Separate DB dev/tests/integration/etc/install-config-mysql.php.dist Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 20. $ vendor/bin/phpunit -c dev/tests/integration/phpunit.xml Could not read "dev/tests/integration/phpunit.xml". Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 21. $ cd dev/tests/integration $ ../../../vendor/bin/phpunit Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 22. Every run gets it's own etc, pub and var dirs dev/tests/integration/tmp/ sandbox-0-b79c13eb842cf3211459b11c775bfbde/ Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 23. BUZZWORD III: TDD Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 24. WHAT IS TDD? Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 25. THE 3 RULES Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 26. I. No production code without a failing unit test Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 27. II. Once there is a failing unit test, stop and make it pass by writing production code Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 28. III. Once the test passes, stop writing production code until you have a failing unit test again Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 29. TDD FOR MAGENTO 2 Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 30. NO DIFFERENCE Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 31. </TDD> Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 32. To learn more about TDD, check out the Clean Coders Videos from Robert C. Martin http://cleancoders.com (or do a training) Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 33. INTEGRATION TESTS FOR MAGENTO 2 Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 34. VERY SPECIFIC Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 35. PLATFORM KNOWLEDGE Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 36. Magento 2 Testing Framework dev/tests/integration/framework Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 37. Test Framework ObjectManager MagentoTestFrameworkObjectManager::getInstance() Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 38. Dependencies $configReader = $objectManager->create(Reader::class); $deploymentConfig = $objectManager->create( DeploymentConfig::class, ['reader' => $configReader] ); Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 39. BUZZWORD IV FIXTURES Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 40. Fix the system into a known state before a test is executed. Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 41. Simple PHP Scripts Relative to dev/tests/integration/testsuite Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 42. /** * @magentoDataFixture Magento/Sales/_files/order.php * @magentoDataFixture Magento/Customer/_files/customer.php */ public function testSomethingWithAnOrderAndACustomer() { // ... Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 43. CONFIG FIXTURES Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 44. Store Scope /** * @magentoConfigFixture current_store catalog/price/scope 1 */ public function testDoesSomeoneReadThisHelpMeLetMeOut() { // ... Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 45. Global Scope /** * @magentoConfigFixture currency/options/allow USD */ public function testHowMashAndPieTastes() { // ... Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 46. BUZZWORD V TEST ISOLATION Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 47. FRESH INSTALL FOR EACH TEST RUN Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 48. dev/tests/integration/phpunit.xml.dist <phpunit> ... <php> ... <const name="TESTS_CLEANUP" value="enabled"/> ... </php> ... </phpunit> Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 49. TESTS_CLEANUP == disabled SPEEDS THINGS UP Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 50. TESTS_CLEANUP == disabled MANUAL CLEANUP REQUIRED Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 51. integration/tmp/sandbox-* Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 52. DATABASE ISOLATION Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 53. TRANSACTIONS OR ROLLBACK SCRIPTS Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 54. TRANSACTIONS /** * @magentoDbIsolation enabled */ public function testWithoutSideEffects { // ... Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 55. TRANSACTIONS /** * @magentoDataFixture Magento/Foo/_files/bar.php */ public function testTheFixtureIsAppliedWithinATransaction { // ... Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 56. ROLLBACK SCRIPTS /** * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoDbIsolation disabled */ public function testTransactionalCode() { // ... Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 57. Before Test include 'Magento/Customer/_files/customer.php'; Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 58. After Test include 'Magento/Customer/_files/customer_rollback.php'; Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 59. APPLICATION ISOLATION Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 60. REINSTANTIATE ALMOST EVERYTHING Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 61. RESET MAGENTO AFTER TEST /** * @magentoAppIsolation enabled */ public function testTestWithSingletons() { Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 62. Controller Tests: Automatic reset class FooBarIndexActionTest extends MagentoTestFrameworkTestCaseAbstractController { public function testTheLayoutIsRendered() { $this->dispatch('foo/bar/index'); Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 63. REMEMBER THIS Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 64. ISOLATE YOUR TESTS Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 65. AND ALL WILL BE GOOD Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 66. [breathing pause] Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 67. APPLICATION AREA Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 68. APP AREAS global frontend adminhtml Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 69. /** * @magentoAppArea frontend */ class AddressesTest extends PHPUnit_Framework_TestCase { Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 70. MORE AREAS Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 71. webapi_rest webapi_soap cron Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 72. MagentoTestFrameworkAppState Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 73. public function testPluginInWebapiRestScope() { $class = MagentoTestFrameworkAppState::class; $appAreaState = $this->objectManager->get($class); $appAreaState->setAreaCode('webapi_rest'); Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 74. protected function tearDown() { // ... $appAreaState->setAreaCode(null); } Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 75. ACTION [CONTROLLER] TESTS Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 76. FRONTEND MagentoTestFrameworkTestCase AbstractController ADMINHTML MagentoTestFrameworkTestCase AbstractBackendController Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 77. EXAMPLE! Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 78. Event Observer for: sales_order_place_after Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 79. I. TESTING THE CONFIGURATION Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 80. public function testTheModuleRegistersASalesOrderPlaceAfterObserver() { $class = MagentoFrameworkEventConfig::class; $eventConfig = ObjectManager::getInstance()->create($class); $observers = $eventConfig->getObservers('sales_order_place_after'); $this->assertArrayHasKey('meetup_observer', $observers); $expectedClass = MeetupObserverObserverSalesOrderPlaceAfter::class; $this->assertSame($expectedClass, $observers['meetup_observer']['instance']); $this->assertFalse($observers['meetup_observer']['shared']); } Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 81. 1/2) Get the config in array format $class = MagentoFrameworkEventConfig::class; $eventConfig = ObjectManager::getInstance()->create($class); $event = 'sales_order_place_after'; $observers = $eventConfig->getObservers($event); Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 82. 2/2) Assert config values $this->assertArrayHasKey('meetup_observer', $observers); $this->assertSame( SalesOrderPlaceAfter::class, $observers['meetup_observer']['instance'] ); $this->assertFalse($observers['meetup_observer']['shared']); Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 83. II. TESTING THE OBSERVER Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 84. O_0(NOTHING TO TEST) Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 85. III. INTEGRATION TEST Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 86. Our observer has no side effects. We have to improvise... Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 87. /** * @magentoDataFixture Magento/Sales/_files/order.php */ public function testSalesOrderPlaceAfterObserverIsCalled() { $this->injectMockObserverWithExpectation(); $order = $this->getOrderFixture(); $this->objectManager ->create(OrderManagementInterface::class) ->place($order); } Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 88. public function injectMockObserverWithExpectation() { $mockObserver = $this->getMock(SalesOrderPlaceAfter::class); $mockObserver->expects($this->once())->method('execute'); $this->registerObserverTestDouble($mockObserver); } Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 89. private function registerObserverTestDouble($mockObserver) { $class = MagentoFrameworkEventConfigData::class; $eventConfigData = $this->objectManager->get($class); $event = 'sales_order_place_after'; $name = 'meetup_observer'; $eventConfigData->merge( [$event => [$name => ['shared' => true]]] ); // ... } Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 90. private function registerObserverTestDouble($mockObserver) { // ... $this->objectManager->addSharedInstance( $mockObserver, SalesOrderPlaceAfter::class ); } Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 91. /** * @magentoDataFixture Magento/Sales/_files/order.php */ public function testSalesOrderPlaceAfterObserverIsCalled() { // ... $order = $this->getOrderFixture(); // ... Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 92. private function getOrderFixture() { $class = OrderRepositoryInterface::class; $orderRepository = $this->objectManager->create($class); $criteria = $this->objectManager ->create(SearchCriteriaBuilder::class) ->addFilter('increment_id', '100000001') ->create(); $result = $orderRepository->getList($criteria); return array_values($result->getItems())[0]; } Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 93. /** * @magentoDataFixture Magento/Sales/_files/order.php */ public function testSalesOrderPlaceAfterObserverIsCalled() { $this->injectMockObserverWithExpectation(); $order = $this->getOrderFixture(); $this->objectManager ->create(OrderManagementInterface::class) ->place($order); } Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 94. GO FORTH AND TESTALL THINGS! Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 95. ONE MORE THING... Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 96. MAGE2KATAS Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 97. MAGE2KATAS > Screencast Series > Examples > Code Katas mage2katas.com Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp
  • 98. THANK YOU <3 Getting your hands dirty Testing Magento 2 - Magento London Meetup, Feb. 2016 - ! - contact@vinaikopp.com - twitter://@VinaiKopp