Files
FOSSBilling/tests/modules/Theme/Model/ThemeTest.php
T
Adam 11a1906ee7 Fix broken module tests (#867)
* Fix typo in Email module tests

Fix missing semicolon in tests for Email module causing PHPUnit to fail.

* Fix module test errors due to RedBean

Fix module tests causing error due to RedBean when being mocked in PHPUnit.

* Fix module test failures

Update module tests to fix failures, and remove obsoleted tests causing failure.
2023-02-27 10:38:20 -08:00

121 lines
3.6 KiB
PHP

<?php
namespace Box\Mod\Theme\Model;
class ThemeTest extends \BBTestCase {
private $existingTheme = 'huraga';
public function testgetName()
{
$themeModel = new \Box\Mod\Theme\Model\Theme($this->existingTheme);
$this->assertEquals($this->existingTheme, $themeModel->getName());
}
public function testNotExistingTheme()
{
$themeName = 'not existing theme';
$this->expectException(\Box_Exception::class);
$this->expectExceptionMessage(sprintf('Theme "%s" does not exist', $themeName));
new \Box\Mod\Theme\Model\Theme($themeName);
}
public function testisAdminAreaTheme()
{
$theme = new \Box\Mod\Theme\Model\Theme($this->existingTheme);
$result = $theme->isAdminAreaTheme();
$this->assertIsBool($result);
}
public function testisAssetsPathWritable()
{
$theme = new \Box\Mod\Theme\Model\Theme($this->existingTheme);
$result = $theme->isAssetsPathWritable();
$this->assertIsBool($result);
}
public function testgetSnippets()
{
$theme = new \Box\Mod\Theme\Model\Theme($this->existingTheme);
$result = $theme->getSnippets();
$this->assertIsArray($result);
}
public function testgetUploadedAssets()
{
$theme = new \Box\Mod\Theme\Model\Theme($this->existingTheme);
$result = $theme->getUploadedAssets();
$this->assertIsArray($result);
}
public function testgetSettingsPageHtml()
{
$theme = new \Box\Mod\Theme\Model\Theme($this->existingTheme);
$result = $theme->getSettingsPageHtml();
$this->assertIsString($result);
}
public function testgetPresetsFromSettingsDataFile()
{
$theme = new \Box\Mod\Theme\Model\Theme($this->existingTheme);
$result = $theme->getPresetsFromSettingsDataFile();
$this->assertIsArray($result);
}
public function testgetCurrentPreset()
{
$theme = new \Box\Mod\Theme\Model\Theme($this->existingTheme);
$result = $theme->getCurrentPreset();
$this->assertIsString($result);
}
public function testgetPresetFromSettingsDataFile()
{
$theme = new \Box\Mod\Theme\Model\Theme($this->existingTheme);
$result = $theme->getPresetFromSettingsDataFile('default');
$this->assertIsArray($result);
}
public function testgetUrl()
{
$theme = new \Box\Mod\Theme\Model\Theme($this->existingTheme);
$result = $theme->getUrl();
$this->assertIsString($result);
}
public function testgetPathConfig()
{
$theme = new \Box\Mod\Theme\Model\Theme($this->existingTheme);
$result = $theme->getPathConfig();
$this->assertIsString($result);
$this->assertTrue(strpos($result, 'config') !== false);
}
public function testgetPathAssets()
{
$theme = new \Box\Mod\Theme\Model\Theme($this->existingTheme);
$result = $theme->getPathAssets();
$this->assertIsString($result);
$this->assertTrue(strpos($result, 'assets') !== false);
}
public function testgetPathHtml()
{
$theme = new \Box\Mod\Theme\Model\Theme($this->existingTheme);
$result = $theme->getPathHtml();
$this->assertIsString($result);
$this->assertTrue(strpos($result, 'html') !== false);
}
public function testgetPathSettingsDataFile()
{
$theme = new \Box\Mod\Theme\Model\Theme($this->existingTheme);
$result = $theme->getPathSettingsDataFile();
$this->assertIsString($result);
$this->assertTrue(strpos($result, 'settings_data.json') !== false);
}
}