Topic: Magento 2

Magento 2 Functional Testings (MTAF) 0


Magetno 2 comes with built in functional test framework.(MTAF) This is also available for Magento 1 too. Here is the quick step by step guide to how to run these functional test cases.

Prerequesties

  • Working Magento 2 installation
  • Disable admin security key urls from magento admin panel. Store=>Config=>Advanced=>Admin=>Add security key url=NoSelection_003
  • Firefox or Google chrome web browser
  • Java runtime installed in your machine
  • PHP Composer

How to Run

  • Got to <magento root>/dev/tests/functional/.
  • Run composer install to install required dependancies. This will download mtaf, selinium RC etc to vendor folder. [composer install]
  • Run [php utils/generate/factory.php] after composer install to generate required factories.
  • Open phpunit.xml and update urls

<php>

<env name="app_frontend_url" value="http://magento2.local.com/index.php/" />

<env name="app_backend_url" value="http://magento2.local.com/index.php/admin/" />

<env name="testsuite_rule" value="basic" />

<env name="testsuite_rule_path" value="Magento/Mtf/TestSuite/InjectableTests" />

<env name="log_directory" value="var/log" />

<env name="events_preset" value="base" />

<env name="module_whitelist" value="Magento_Install" />

<env name="basedir" value="var/log" />

<env name="credentials_file_path" value="./credentials.xml.dist" />

</php>
  • Open etc/config.xml and update login credentials

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="config.xsd">

<application>

<reopenBrowser>testCase</reopenBrowser>

<backendLogin>admin</backendLogin>

<backendPassword>*****</backendPassword>

<appBackendUrl>http://magento2.local.com/admin/</appBackendUrl>

<backendLoginUrl>admin/auth/login</backendLoginUrl>

</application>

<install>

<host>127.0.0.1</host>

<user>root</user>

<password>******</password>

<dbName>default</dbName>

<baseUrl>http://magento2.local.com/</baseUrl>

<backendName>admin</backendName>

</install>

</config>
  • Those are the minimum configuration to get test cases runinng. You can find more descriptive configuration documents under vendor/magento/mtf/docs/
  • Start Selenium by [java -jar vendor/netwing/selenium-server-standalone/selenium-server-standalone-2.44.0.jar] your version may variy
  • Now run phpunit from <magento root>/dev/tests/functional/

Following are all the commands that used.


cd <magento root>/dev/tests/functional

composer install

vi phpunit.xml (change urls)

vi etc/config.xml (change urls/credentials)

java -jar vendor/netwing/selenium-server-standalone/selenium-server-standalone-2.44.0.jar

phpunit

Please upgrade your database: Run “bin/magento setup:upgrade” from the Magento root directory. 0


2

When you try to run Magento 2 and if you get above error,

copy this code

bin/magento setup:upgrade

Go to your Magento 2 root folder.

Open the Git Bash ( I think this will work on command prompt as well )
Paste the code and Enter.

a

It will execute and once it completed, Run Magento 2.

SQLSTATE[HY000] [1045] Access denied for user ‘root’@’localhost’ (using password: YES) 0


1

When you try to run Magento 2 and If you get this error message, possible reason is wrong username or password.

You can change this by editing, below information.

Go to app folder > Etc > and open env.php

In this file, you can find below code section

array (
'host' => 'localhost',
'dbname' => 'magento2',
'username' => 'root',
'password' => '',
'model' => 'mysql4',
'engine' => 'innodb',
'initStatements' => 'SET NAMES utf8;',
'active' => '1',
)

Replace your database information.

How to Change database details in Magento 2 0


You can do this easily 🙂

Go to app folder > Etc > and open env.php

In this file, you can find below code section

array (
'host' => 'localhost',
'dbname' => 'magento2',
'username' => 'root',
'password' => '',
'model' => 'mysql4',
'engine' => 'innodb',
'initStatements' => 'SET NAMES utf8;',
'active' => '1',
),

Edit the details and add your database information.

That’s it 🙂

Introduction to Magento 2 0


Magento 2 is going to be released in early 2016 with new architectural and functional improvements. You can try community edition freely from git hub. (git link) Followings are some new features available in community edition.

  • Bootstrap for autoloading.
  • Dependancy Injection for object loading.(DI) Factory methods are no longer exists.
  • Zend 2.
  • New module structure. All blocks / layouts / templates are in same folder.
  • Core was completely removed. Adminhtml was replaced by backend.
  • core_resource table was replaced by setup_module.
  • Unlimited theme fallback. Introduced in CE 1.6 upward. theme.xml under design theme etc folder.
  • Full page cache.
  • Built in varnish cache.
  • Less for css.
  • Built in less compiler.
  • Layout files can be extended instead of copying all contents.
  • Composer for php dependancy management.

It gives significant performance improvements with all these features. And there are more customization options are available with minimum conflicts. Plugins and Preferances are major customization options they added. Plugins allow us to intercept method call and Preferances allow to change run time class in DI. Also it gives more flexible customizations with DI by changing constructor params via di.xml. Indexed php is no longer exsists, it uses bin/magento to achive all shell functions like indexing, log cleaning etc. Also there some new functions available through magento. Follwing diagram shows general process flow of Magento2.

 

arc