Skip to content

Commit

Permalink
Dev: Add unit-test class for template controller
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Oct 16, 2017
1 parent afe1019 commit 0af681d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions phpunit.xml
Expand Up @@ -9,5 +9,8 @@
<testsuite name="Models">
<directory>tests/models</directory>
</testsuite>
<testsuite name="Controllers">
<directory>tests/controllers</directory>
</testsuite>
</testsuites>
</phpunit>
45 changes: 45 additions & 0 deletions tests/controllers/TemplateControllerTest.php
@@ -0,0 +1,45 @@
<?php

namespace ls\tests;

use PHPUnit\Framework\TestCase;

/**
* @since 2017-10-15
* @group tempcontr
*/
class TemplateControllerTest extends TestBaseClass
{

/**
* Test copy a template.
*/
public function testCopyTemplate()
{
\Yii::app()->session['loginID'] = 1;
\Yii::import('application.controllers.admin.templates', true);
\Yii::import('application.helpers.globalsettings_helper', true);

// Clean up from last test.
\Template::model()->deleteAll('name = \'foobartest\'');

// Remove folder from last test.
$newname = 'foobartest';
$newdirname = \Yii::app()->getConfig('usertemplaterootdir') . "/" . $newname;
@exec('rm -r ' . $newdirname);

// Simulate a POST.
$_POST['newname'] = $newname;
$_POST['copydir'] = 'default';

$contr = new \templates(new DummyController('dummyid'));
$contr->templatecopy();
}

/**
* @todo Copy template folder that does not exist.
*/
public function testCopyWrongFolder()
{
}
}

0 comments on commit 0af681d

Please sign in to comment.