Skip to content

Commit

Permalink
Merge pull request #14616 from jdalsem/6.0-fixes
Browse files Browse the repository at this point in the history
chore(tests): handle cases where plugins do not have items to test
  • Loading branch information
jeabakker committed May 14, 2024
2 parents ffe68ae + 9ca1d65 commit 1ea589d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,22 @@ public static function actionsProvider(): array {
}
}

if (empty($result)) {
// hack so test can check if there are no actions provided
$result[] = [null, null];
}

return $result;
}

/**
* @dataProvider actionsProvider
*/
public function testCanRequestActionWithoutParameters($name, $access, \ElggPlugin $plugin = null) {
if (!isset($name)) {
$this->markTestSkipped('no plugin actions to test');
}

$this->registerPluginActions($plugin);

parent::testCanRequestActionWithoutParameters($name, $access);
Expand All @@ -50,6 +59,10 @@ public function testCanRequestActionWithoutParameters($name, $access, \ElggPlugi
* @dataProvider actionsProvider
*/
public function testCanRequestActionWithoutParametersViaAjax($name, $access, \ElggPlugin $plugin = null) {
if (!isset($name)) {
$this->markTestSkipped('no plugin actions to test');
}

$this->registerPluginActions($plugin);

parent::testCanRequestActionWithoutParametersViaAjax($name, $access);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,22 @@ public static function languageProvider(): array {
}
}

if (empty($result)) {
// hack so test can check if there are no translations provided
$result[] = [null, null];
}

return $result;
}

/**
* @dataProvider languageProvider
*/
public function testCanLoadTranslations(\ElggPlugin $plugin, string $language) {
public function testCanLoadTranslations(?\ElggPlugin $plugin, ?string $language) {
if (!isset($plugin)) {
$this->markTestSkipped('no plugin translations to test');
}

$this->translator->setCurrentLanguage($language);

$this->assertTrue($this->translator->registerTranslations($plugin->getPath() . 'languages/', false, $language));
Expand All @@ -85,7 +94,11 @@ public function testCanLoadTranslations(\ElggPlugin $plugin, string $language) {
*
* @dataProvider languageProvider
*/
public function testCanCalculateLanguageCompleteness(\ElggPlugin $plugin, string $language) {
public function testCanCalculateLanguageCompleteness(?\ElggPlugin $plugin, ?string $language) {
if (!isset($plugin)) {
$this->markTestSkipped('no plugin translations to test');
}

$this->translator->setCurrentLanguage($language);

$this->translator->registerTranslations($plugin->getPath() . 'languages/', false, $language);
Expand Down Expand Up @@ -123,7 +136,11 @@ public function testCanCalculateLanguageCompleteness(\ElggPlugin $plugin, string
*
* @dataProvider languageProvider
*/
public function testCanEncodeTranslations(\ElggPlugin $plugin, string $language) {
public function testCanEncodeTranslations(?\ElggPlugin $plugin, ?string $language) {
if (!isset($plugin)) {
$this->markTestSkipped('no plugin translations to test');
}

$translations = Includer::includeFile("{$plugin->getPath()}/languages/{$language}.php");

$this->assertIsArray($translations);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,22 @@ public static function viewsProvider(): array {
}
}

if (empty($result)) {
// hack so test can check if there are no views provided
$result[] = [null, null, null, null, null];
}

return $result;
}

/**
* @dataProvider viewsProvider
*/
public function testViewStackRegistrations(\ElggPlugin $plugin, $view, $viewtype, $path, $is_simplecache_view) {
public function testViewStackRegistrations(?\ElggPlugin $plugin, $view, $viewtype, $path, $is_simplecache_view) {
if (!isset($plugin)) {
$this->markTestSkipped('no plugin views to test');
}

$this->startPlugin($plugin->getID(), false);

$this->assertFileExists($path);
Expand Down

0 comments on commit 1ea589d

Please sign in to comment.