PHP code example of helbrary / nette-tester-extension
1. Go to this page and download the library: Download helbrary/nette-tester-extension library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
helbrary / nette-tester-extension example snippets
sh
__DIR__ . '/../../../../vendor/helbrary/nette-tester-extension/src/BasePresenterTester.php';
finalclassTestAccountPresenterextends \Helbrary\NetteTesterExtension\BasePresenterTester{
/**
* @var \Model\UserModel
*/private $userModel;
/**
* @var bool|\Model\User
*/private $testingUser;
/**
* TestGoodsPresenter constructor.
*/publicfunction__construct(){
parent::__construct('Front:Account'); // Here is defined presenter which we want test$this->userModel = $this->container->getByType('\Model\UserModel');
$this->testingUser = $this->userModel->find()->fetch(); // get some user from db
}
/**
* Test detail action of account presenter
*/publicfunctiontestDetail(){
// if no user is logged in, expected redirect to Sign in$this->checkRedirectTo(array(
'action' => 'detail',
'id' => 8, // parameter id for action detail
), 'Front:Sign:in');
// if some user is logged in, expected that action detail will be render without error// after send this request is logged in user with id $this->testingUser->id$this->checkRequestNoError(array(
'action' => 'detail',
), 'GET', $this->testingUser->id);
}
}
$testCase = new TestAccountPresenter();
$testCase->run();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.