フォームでランダムな名前を生成するために使用する名前の配列があり、それを複数の関数で使用したいと考えています。
class TestMyTest extends PHPUnit_Extensions_Selenium2TestCase {
public function setUp()
{
$this->setHost('localhost');
$this->setPort(4444);
$this->setBrowser("firefox");
$this->setBrowserUrl("xxxxxxxxxxxxxxxxxx");
}
public $firstNameArray = array(
"Howard",
"Sheldon",
"Leonard",
"Rajesh"
);
public $lastNameArray = array(
"Wolowitz",
"Cooper",
"Hofstadter",
"Koothrappali"
);
public function testCreateNewCustomer()
{
$name = rand(0,count($firstNameArray));
$this->byId('customer-name')->value($firstNameArray[$name].' '.$lastNameArray[$name]);
$random_phone_nr = rand(1000000,9999999);
$this->byId('customer-phone')->value('070'.$random_phone_nr);
$this->byId('customer-email')->value($firstNameArray[$name].'.'.$lastNameArray[$name].'@testcomp.com');
}
これにより、$name variabel を宣言する行に「Undefined variable: firstNameArray」というエラーが表示されます。使用するすべての関数で同じ配列を宣言する必要はありません。どうすればこれを解決できますか?