-
Notifications
You must be signed in to change notification settings - Fork 988
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV: restructure tests: move controllers
# Conflicts: # tests/controllers/TemplateControllerTest.php # tests/functional/admin/InstallationControllerTest.php
- Loading branch information
1 parent
7dadeae
commit 63219fa
Showing
2 changed files
with
138 additions
and
94 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
namespace ls\tests\controllers; | ||
|
||
use ls\tests\DummyController; | ||
use ls\tests\TestBaseClass; | ||
|
||
/** | ||
* @since 2017-10-15 | ||
* @group tempcontr | ||
* @group template | ||
*/ | ||
class TemplateControllerTest extends TestBaseClass | ||
{ | ||
|
||
/** | ||
* Test copy a template. | ||
* @group copytemplate | ||
*/ | ||
public function testCopyTemplate() | ||
{ | ||
\Yii::app()->session['loginID'] = 1; | ||
\Yii::import('application.controllers.admin.themes', true); | ||
\Yii::import('application.helpers.globalsettings_helper', true); | ||
|
||
// Clean up from last test. | ||
$templateName = 'foobartest'; | ||
\TemplateConfiguration::uninstall($templateName); | ||
\Template::model()->deleteAll('name = \'foobartest\''); | ||
\Permission::model()->deleteAllByAttributes(array('permission' => $templateName,'entity' => 'template')); | ||
|
||
// Remove folder from last test. | ||
$newname = 'foobartest'; | ||
$newdirname = \Yii::app()->getConfig('userthemerootdir') . "/" . $newname; | ||
if (file_exists($newdirname)) { | ||
exec('rm -r ' . $newdirname); | ||
} | ||
|
||
$config = require(\Yii::app()->getBasePath() . '/config/config-defaults.php'); | ||
// Simulate a POST. | ||
$_POST['newname'] = $newname; | ||
// NB: If default theme is not installed, this test will fail. | ||
$_POST['copydir'] = $config['defaulttheme']; | ||
$_SERVER['SERVER_NAME'] = 'localhost'; | ||
|
||
$contr = new \themes(new DummyController('dummyid')); | ||
$contr->templatecopy(); | ||
|
||
$flashes = \Yii::app()->user->getFlashes(); | ||
$this->assertEmpty($flashes, 'No flash messages'); | ||
|
||
$template = \Template::model()->find( | ||
sprintf( | ||
'name = \'%s\'', | ||
$templateName | ||
) | ||
); | ||
$this->assertNotEmpty($template); | ||
$this->assertEquals($templateName, $template->name); | ||
|
||
|
||
|
||
// Clean up. //TODO tearDown | ||
\Template::model()->deleteAll('name = \'foobartest\''); | ||
} | ||
|
||
/** | ||
* @todo Copy template folder that does not exist. | ||
*/ | ||
/* | ||
public function testCopyWrongFolder() | ||
{ | ||
} | ||
*/ | ||
} |
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