1. Go to this page and download the library: Download n-educatio/testbundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
n-educatio / testbundle example snippets
php composer.phar install
php
class LanguageContext extends BaseSubContext
{
/**
* Change website language
*
* @param string $language New langauge
*
* @When /^I change language to ([^"]*)$/
*/
public function changeLanguage($language)
{
$this->setPage(LanguagePanel::NAME);
$this->getPage()->changeLanguage($language);
}
}
php
class LanguagePanel extends BasePageObject
{
const NAME = __CLASS__;
protected $proofSelector = '.t_languages';
/**
* Changes language
*
* @param string $language Language
*/
public function changeLanguage($language)
{
//Nasze uchwyty w tym przypadku to
//t_language_polish
//t_language_english
$this->get('language_' . $language)->click();
}
}
php
class LoadAmyFreshUserData extends LoadActorUserData
{
const NAME = __CLASS__;
protected $order = 100;
protected $userData = array(
'AmyFresh' => array(
"username" => "[email protected]",
"description" => "Teacher that visits the app for the first time and wants to give it a try",
"roles" => "ROLE_USER",
"firstname" => "Amy",
"lastname" => "Fresh",
"registered" => false,
),
);
}
php
class LoadJuliaLazyUserData extends LoadActorUserData
{
const NAME = __CLASS__;
protected $order = 101;
protected $userData = array(
'JuliaLazy' => array(
"username" => "[email protected]",
"description" => "User that is only registered in the system",
"roles" => "ROLE_USER",
"firstname" => "Julia",
"lastname" => "Lazy",
"registered" => true,
),
);
}
php
public function mojaMetodaKontekstowa()
{
$this->loadFixtures(array(
KLASA_Z_MOIM_PORZADANYM_FIXTUREM::NAME
));
// Dalej robie coś tam z Fixturesami
// Dla przykładu:
$this->getReference('mojaReferencja')->jakasMetoda();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.