So this is my entire test :
<?php
class FirstCest
{
public function __rand_float($st_num=0,$end_num=1,$mul=1000000)
{
if ($st_num>$end_num) return false;
$this->__rand_float();
return mt_rand($st_num*$mul,$end_num*$mul)/$mul;
}
public function _before(AcceptanceTester $I)
{
//Times to answer questions
$nq = 8; //number of questions
$ncand = 5; //number of candidates
$lexam = 10; //minutes
$smpu = 0.05;
$lexam1 = $lexam * (1- $smpu);
$times = [];
//for ($i=$ncand; $i > 0; $i--) {
$lexam2 = $lexam1 * ( 0.9 + __rand_float(0,0.2,25));
$tques = round($lexam2 / $nq,3);
$ta = 0;
for ($i=$nq; $i > 0 ; $i--) {
$tques1 = $tques * round((__rand_float(0.5,1.5,5)),2);
$ta = $ta + $tques1;
array_push($times, $tquest1);
}
// }
return $times;
}
// test
public function loginSuccessfully(AcceptanceTester $I,$times)
{
$trainees = ['008C108:8706405','008C408:1776723','008B108:9315051','008BD08:4357300','008BF08:4235645','008C308:8571541','008B008:7139762','008BB08:8942468','008BC08:6648592','6648592:8504197','008C608:6219682','008AE08:2728576','008AF08:9407850'];
$user = $trainees[rand(0,count($trainees))];
$credentials = explode(':',$user,2);
unset($trainees[$user]);
$I->amOnPage('');
$I->waitForElementClickable('//*[@id="submitLogin"]');
$I->fillField('username',$credentials[0]);
$I->fillField('password',$credentials[1]);
$I->click('//*[@id="submitLogin"]');
//preliminaries
$I->waitForElementClickable('//*[@id="Proceed"]');
$I->click('//*[@id="Proceed"]');
$I->waitForElementClickable('//*[@id="pCheckbox"]/span');
$I->click('//*[@id="pCheckbox"]/span');
$I->waitForElementClickable('//*[@id="Proceed"]');
$I->click('//*[@id="Proceed"]');
$I->waitForElementClickable('//*[@id="Proceed"]');
$I->click('//*[@id="Proceed"]');
$I->waitForElementClickable('//*[@id="pCheckbox"]/span');
$I->click('//*[@id="pCheckbox"]/span');
$I->waitForElementClickable('//*[@id="Proceed"]');
$I->click('//*[@id="Proceed"]');
$I->waitForElementClickable('//*[@id="Proceed"]');
$I->click('//*[@id="Proceed"]');
$I->waitForElementClickable('//*[@id="pCheckbox"]/span');
$I->click('//*[@id="pCheckbox"]/span');
$I->waitForElementClickable('//*[@id="Proceed"]');
$I->click('//*[@id="Proceed"]');
//start exam
$I->waitForElementNotVisible('//*[@id="oleWaitMessage"]', 200);
for ($q=count($times); $q > 0 ; $q--) {
$I->waitForElementClickable('//*[@id="rb_0"]');
$I->wait($times[$q]);
$I->click('//*[@id="rb_'.rand(0,2).'"]');
$I->waitForElementClickable('//*[@id="oleNextItemBtn"]');
$I->click('//*[@id="oleNextItemBtn"]');
}
$I->waitForElementClickable('//*[@id="oleSubmitBtn"]');
$I->wait(2);
$I->click('//*[@id="oleSubmitBtn"]');
$I->waitForElementClickable('//*[@id="yui-gen0-button"]');
$I->wait(2);
$I->click('//*[@id="yui-gen0-button"]');
}
}
As you can see I have a function called __rand_float()
which I use in the _before
method. So when I run this test I get the following:
There was 1 error:
---------
1) FirstCest: Login successfully
Test tests\acceptance\FirstCest.php:loginSuccessfully
[Error] Call to undefined function __rand_float()
#1 D:\Programas\xampp\htdocs\robo2\tests\acceptance\FirstCest.php:30
#2 FirstCest->_before
What may be causing this?
Aucun commentaire:
Enregistrer un commentaire