Magium is a testing tool that I am working on. Here is an intro.
Install with one, simple command
composer require magium/magento
Turn simple Selenium commands into simpler API calls
This code navigates to a product
class ProductNavigationTest extends AbstractMagentoTestCase { protected $productName = 'Pearl Stud Earrings'; public function testNavigateToJewelry() { $this->commandOpen($this->getTheme()->getBaseUrl()); $this->getNavigator()->navigateTo($theme->getNavigationPathToProductCategory()); $this->getNavigator(Product::NAVIGATOR)->navigateTo($this->productName); $this->assertTitleContains($this->productName); } }
Turn crazy-hard Selenium commands into simple API calls
This code adds a product to the cart, checks out as a customer, and navigates to the order on the customer frontend
class CustomerCheckoutTest extends AbstractMagentoTestCase { public function testBasicCheckout() { $this->commandOpen($this->getTheme()->getBaseUrl()); $addToCart = $this->getAction(AddItemToCart::ACTION); $addToCart->addSimpleProductToCartFromCategoryPage(); $this->setPaymentMethod('CashOnDelivery'); $customerCheckout= $this->getAction(CustomerCheckout::ACTION); $customerCheckout->execute(); $orderId = $this->getExtractor(OrderId::EXTRACTOR)->getOrderId(); $this->getNavigator(AccountHome::NAVIGATOR)->navigateTo(); $this->getNavigator(NavigateToOrder::NAVIGATOR)->navigateTo($orderId); } }
Build tests that work across multiple different Magento versions
This code builds an initial test and then simply extends the original test, changing the theme configuration
class ProductNavigationTest extends AbstractMagentoTestCase { public function testNavigateToCategory() { $this->commandOpen($this->getTheme()->getBaseUrl()); $this->getNavigator()->navigateTo($theme->getNavigationPathToProductCategory()); } } // Class extends the original test for testing Magento CE 1.8 class MagentoCE18ProductNavigationTest extends ProductNavigationTest { protected function setUp() { parent::setUp(); $this->switchThemeConfiguration('Magium\Magento\Themes\Magento18\ThemeConfiguration'); } } // Class extends the original test for testing Magento EE 1.14 class MagentoEE114ProductNavigationTest extends ProductNavigationTest { protected function setUp() { parent::setUp(); $this->switchThemeConfiguration('Magium\Magento\Themes\MagentoEE114\ThemeConfiguration'); } }
Get Started
- Download Selenium Server and Chrome WebDriver
- Start Selenium Server
java -Dwebdriver.chrome.driver=chromedriver.exe -jar selenium-server-standalone-2.48.2.jar
- Download and install Composer (or create a new project in your IDE with Composer support
- Add Magium to your project for the software you will be testing. For example, if you are testing Magento.
composer require magium/magento
Magium is built using PHP and PHPUnit, but if you aren’t very familiar with either don’t worry, it’s actually not that hard. If you are using an IDE (it’s probably the best $100 you will spend in a long time) a significant amount of functionality can be built using only minimal PHP coding knowledge.
Here are some content you can get from the main site.