Integration test improvements
This commit is contained in:
@@ -63,13 +63,9 @@ abstract class BaseTestCase extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
protected $password = null;
|
||||
|
||||
protected function createApplication($userName = null, $password = null)
|
||||
protected function createApplication($userName = null, $password = null, $clearCache = true)
|
||||
{
|
||||
if (isset($userName) && isset($password)) {
|
||||
return $this->espoTester->getApplication(true, $userName, $password);
|
||||
}
|
||||
|
||||
return $this->espoTester->getApplication(true);
|
||||
return $this->espoTester->getApplication(true, $userName, $password, $clearCache);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +98,10 @@ abstract class BaseTestCase extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->espoTester = new Tester($params);
|
||||
$this->espoTester->initialize();
|
||||
|
||||
$this->beforeStartApplication();
|
||||
$this->espoApplication = $this->createApplication($this->userName, $this->password);
|
||||
$this->afterStartApplication();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
@@ -111,4 +110,14 @@ abstract class BaseTestCase extends \PHPUnit_Framework_TestCase
|
||||
$this->espoTester = NULL;
|
||||
$this->espoApplication = NULL;
|
||||
}
|
||||
|
||||
protected function beforeStartApplication()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected function afterStartApplication()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ class Tester
|
||||
|
||||
protected $testDataPath = 'tests/integration/testData';
|
||||
|
||||
protected $defaultUserPassword = '1';
|
||||
|
||||
private $application;
|
||||
|
||||
private $dataLoader;
|
||||
@@ -75,13 +77,19 @@ class Tester
|
||||
return $returns;
|
||||
}
|
||||
|
||||
public function getApplication($reload = false, $userName = null, $password = null)
|
||||
public function getApplication($reload = false, $userName = null, $password = null, $clearCache = true)
|
||||
{
|
||||
if (!isset($this->application) || $reload) {
|
||||
|
||||
if ($clearCache) {
|
||||
$this->clearCache();
|
||||
}
|
||||
|
||||
$this->application = new \Espo\Core\Application();
|
||||
$auth = new \Espo\Core\Utils\Auth($this->application->getContainer());
|
||||
|
||||
if (isset($userName) && isset($password)) {
|
||||
if (isset($userName)) {
|
||||
$password = isset($password) ? $password : $this->defaultUserPassword;
|
||||
$auth->login($userName, $password);
|
||||
} else {
|
||||
$auth->useNoAuth();
|
||||
@@ -155,4 +163,11 @@ class Tester
|
||||
$this->getDataLoader()->loadFiles($this->params['pathToFiles']);
|
||||
}
|
||||
}
|
||||
|
||||
public function clearCache()
|
||||
{
|
||||
$fileManager = new \Espo\Core\Utils\File\Manager();
|
||||
|
||||
return $fileManager->removeInDir('data/cache');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user