cancel
Showing results for 
Search instead for 
Did you mean: 

phpUnit test returns null

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

phpUnit test returns null

I have written code and test. I want to test that the function return what expected. The issue that I have is that the test returns null. but I know that the Magento function return 1 when no categories have been created (I created simple module with button in admin area to see what might be wrong). I am new at testing so please can anyone tell me what am I doing wrong? (The function when it is completed should return false when getCount is 1 and otherwise when categories exists return true). I have understood that the test I have written is not Unit test but Integration test, because it needs result from external function.

 

My Module code

public function anyCategoriesExist() {
$totalCategoriesInStore = $this->_categoryManagement->getCount();
return $totalCategoriesInStore;
}


My test

 

public function setUp(){
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\Objectmanager($this);
$this->anyCategoriesExist=$objectManager->getObject('Vendor\Module\Model\categoryManagement');
}
public function test categoryExists(){
$this->assertEuqals(1, $this->anyCategoriesExist->anyCategoriesExist());
}