Reputation: 304
Setup function call multiple time. I need to execute only once. I am new to the phpunit.can anyone give the solution for this.I need to execute 4 tests in this file and i need to use the same variable name
class XSCBookModelTest extends TestCase
{
public $categoryID;
public $categoryName = "Motivations";
public $parentID = 0;
protected function setUp()
{
$this->XSCBooksModelObj = new XSCBooksModel();
$categoryObjModel = new XSCCategoryModel();
$this->categoryID = $categoryObjModel->AddCategory($this->categoryName, $this->parentID);
$this->setup = 0;
$this->assertNotEquals($this->categoryID, 0);
}
Upvotes: 2
Views: 696
Reputation: 8326
setUp()
is supposed to be called once before each test method, see the documentation for details.
Upvotes: 1