mirror of
https://github.com/humhub/humhub.git
synced 2025-01-16 21:58:17 +01:00
Fix loading of fixture spaces on tests (#5002)
* Fix loading of fixture spaces on tests * Update CHANGELOG.md
This commit is contained in:
parent
b8b48e81af
commit
2f8623264c
@ -12,6 +12,7 @@ HumHub Changelog
|
||||
- Enh #4972: Fix enabling to send notification on remove user from group
|
||||
- Fix #4985: Fix Activity Mail QueryParams on console mode
|
||||
- Fix #4989: Translate profile field title in admin list
|
||||
- Fix #5002: Fix loading of fixture spaces on tests
|
||||
|
||||
|
||||
1.8.1 (March 12, 2021)
|
||||
|
@ -19,16 +19,25 @@ class BaseTester extends \Codeception\Actor
|
||||
|
||||
public function getFixtureSpace(int $index) : ?Space
|
||||
{
|
||||
if (method_exists($this, 'haveFixtures') && method_exists($this, 'grabFixture')) {
|
||||
$this->haveFixtures(['space' => SpaceFixture::class]);
|
||||
return $this->grabFixture('space', $index);
|
||||
} else {
|
||||
// Acceptance tests have no the methods above, try to get spaces from DB instead:
|
||||
if (!isset($this->spaces)) {
|
||||
$this->spaces = Space::find()->orderBy('id')->all();
|
||||
}
|
||||
return isset($this->spaces[$index]) ? $this->spaces[$index] : null;
|
||||
if (isset($this->spaces[$index])) {
|
||||
return $this->spaces[$index];
|
||||
}
|
||||
|
||||
if (method_exists($this, 'haveFixtures') && method_exists($this, 'grabFixture')) {
|
||||
if (!isset($this->spaces)) {
|
||||
// Don't try to load spaces twice because it is delete all space records from related tables
|
||||
$this->haveFixtures(['space' => SpaceFixture::class]);
|
||||
}
|
||||
$this->spaces[$index] = $this->grabFixture('space', $index);
|
||||
} else if (!isset($this->spaces)) {
|
||||
// Acceptance tests have no the methods above, try to get spaces from DB instead:
|
||||
$this->spaces = Space::find()->orderBy('id')->all();
|
||||
if (!isset($this->spaces[$index])) {
|
||||
$this->spaces[$index] = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->spaces[$index];
|
||||
}
|
||||
|
||||
public function getFixtureSpaceGuid(int $index) : string
|
||||
|
@ -235,29 +235,31 @@ class FunctionalTester extends BaseTester
|
||||
$this->amOnSpace(4, $path, $params, $post);
|
||||
}
|
||||
|
||||
public function amOnSpace($guid, $path = '/space/space', $params = [], $post = false)
|
||||
public function amOnSpace($spaceOrIndexOrGuid, $path = '/space/space', $params = [], $post = false)
|
||||
{
|
||||
if(is_bool($params)) {
|
||||
if (is_bool($params)) {
|
||||
$post = $params;
|
||||
$params = [];
|
||||
}
|
||||
|
||||
if(!$path) {
|
||||
if (!$path) {
|
||||
$path = '/space/space';
|
||||
}
|
||||
|
||||
if(is_int($guid)) {
|
||||
$guid = $this->getFixtureSpaceGuid(--$guid);
|
||||
} else if($guid instanceof Space) {
|
||||
$guid = $guid->guid;
|
||||
if(is_int($spaceOrIndexOrGuid)) {
|
||||
$guid = $this->getFixtureSpaceGuid(--$spaceOrIndexOrGuid);
|
||||
} else if(is_string($spaceOrIndexOrGuid)) {
|
||||
$guid = $spaceOrIndexOrGuid;
|
||||
} else if($spaceOrIndexOrGuid instanceof Space) {
|
||||
$guid = $spaceOrIndexOrGuid->guid;
|
||||
} else {
|
||||
$guid = '';
|
||||
}
|
||||
|
||||
$params['cguid'] = $guid;
|
||||
|
||||
if($post) {
|
||||
$route = array_merge([$path], $params);
|
||||
if ($post) {
|
||||
$route = array_merge([$path], $params);
|
||||
$this->sendAjaxPostRequest(Url::toRoute($route), (is_array($post) ? $post : []));
|
||||
} else {
|
||||
$this->amOnRoute($path, $params);
|
||||
|
Loading…
x
Reference in New Issue
Block a user