-
-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Theme Management and write tests
- Loading branch information
1 parent
32e8ff5
commit 4e8f6d3
Showing
8 changed files
with
185 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Leantime\Core\Providers; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
class Theme extends ServiceProvider | ||
{ | ||
/** | ||
* Register any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->app->singleton(\Leantime\Core\Theme::class, \Leantime\Core\Theme::class); | ||
$this->app->alias(\Leantime\Core\Theme::class, "themne"); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
|
||
namespace Unit\app\Domain\Menu\Repositories; | ||
|
||
use Codeception\Test\Unit; | ||
use Leantime\Config\Config; | ||
use Leantime\Core\Configuration\AppSettings; | ||
use Leantime\Core\Configuration\Environment; | ||
use Leantime\Core\Events\EventDispatcher; | ||
use Leantime\Core\Language; | ||
use Leantime\Core\Theme; | ||
use Leantime\Domain\Menu\Repositories\Menu; | ||
use Leantime\Domain\Setting\Repositories\Setting; | ||
use Leantime\Domain\Tickets\Services\Tickets; | ||
|
||
class ThemeTest extends Unit | ||
{ | ||
|
||
use \Codeception\Test\Feature\Stub; | ||
|
||
/** | ||
* The test object | ||
* | ||
* @var Theme | ||
*/ | ||
protected $theme; | ||
|
||
protected $settingsRepoMock; | ||
|
||
protected $languageMock; | ||
|
||
protected $configMock; | ||
|
||
protected $appSettingsMock; | ||
|
||
protected function _before() | ||
{ | ||
|
||
//Mock classes | ||
$this->settingsRepoMock = $this->make(Setting::class, [ | ||
|
||
]); | ||
$this->languageMock = $this->make(Language::class, [ | ||
|
||
]); | ||
|
||
$this->configMock = $this->make(Environment::class, [ | ||
"primarycolor"=> "#123", | ||
"secondarycolor"=> "#123", | ||
|
||
]); | ||
|
||
$this->appSettingsMock = $this->make(AppSettings::class, [ | ||
"appVersion" => "123", | ||
|
||
]); | ||
|
||
//Load class to be tested | ||
$this->theme = new Theme( | ||
settingsRepo: $this->settingsRepoMock, | ||
language: $this->languageMock, | ||
config:$this->configMock, | ||
appSettings: $this->appSettingsMock | ||
); | ||
|
||
} | ||
|
||
protected function _after() | ||
{ | ||
$this->theme = null; | ||
} | ||
|
||
//Write tests below | ||
|
||
/** | ||
* Test GetMenuTypes method | ||
*/ | ||
public function testGetDefaultColorSchemeWithColorEnvSet() { | ||
|
||
$colorScheme = $this->theme->getColorScheme(); | ||
$this->assertEquals("companyColors", $colorScheme); | ||
|
||
} | ||
|
||
/** | ||
* Test GetMenuTypes method | ||
*/ | ||
public function testGetDefaultColorSchemeWithoutEnv() { | ||
|
||
$configMock = $this->make(Environment::class, []); | ||
|
||
$theme = new Theme( | ||
settingsRepo: $this->settingsRepoMock, | ||
language: $this->languageMock, | ||
config: $configMock, | ||
appSettings: $this->appSettingsMock | ||
); | ||
$colorScheme = $theme->getColorScheme(); | ||
$this->assertEquals("themeDefault", $colorScheme); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters