diff --git a/application/controllers/admin/useraction.php b/application/controllers/admin/useraction.php
index f2b8d9c743f..81707cbef74 100755
--- a/application/controllers/admin/useraction.php
+++ b/application/controllers/admin/useraction.php
@@ -705,7 +705,7 @@ private function _refreshtemplates()
if (count($result) == 0) {
$post = new Template;
$post->folder = $tp;
- $post->creator = Yii::app()->session['loginID'];
+ $post->owner_id = Yii::app()->session['loginID'];
try {
$post->save();
diff --git a/application/models/User.php b/application/models/User.php
index 29f44b428c1..f0e21cc0d0b 100644
--- a/application/models/User.php
+++ b/application/models/User.php
@@ -379,7 +379,7 @@ class='btn btn-default btn-xs'>
(Permission::model()->hasGlobalPermission('users', 'update') &&
$this->parent_id == Yii::app()->session['loginID'])) && !Permission::isForcedSuperAdmin($this->uid)) {
//'admin/user/sa/setuserpermissions'
- $setPermissionsUser = "";
+ $setPermissionsUser = "";
}
if ((Permission::model()->hasGlobalPermission('superadmin', 'read')
|| Permission::model()->hasGlobalPermission('templates', 'read'))
diff --git a/tests/TestBaseClassView.php b/tests/TestBaseClassView.php
index d0df4f65a9a..66e4f86f912 100644
--- a/tests/TestBaseClassView.php
+++ b/tests/TestBaseClassView.php
@@ -59,11 +59,7 @@ protected function openAndFindViewTag($name, $view){
*/
protected function findViewTag($name, $view)
{
- $url = $this->getUrl($view);
- $this->openView($url);
- $element = null;
$filename = self::$screenshotsFolder. '/'.$name.'.png';
-
try {
$element = self::$webDriver->wait(2)->until(
WebDriverExpectedCondition::presenceOfAllElementsLocatedBy(
diff --git a/tests/TestBaseClassWeb.php b/tests/TestBaseClassWeb.php
index b4861a5323d..4a92213639f 100644
--- a/tests/TestBaseClassWeb.php
+++ b/tests/TestBaseClassWeb.php
@@ -69,6 +69,48 @@ public static function setUpBeforeClass()
self::$domain = getenv('DOMAIN');
+ self::setUpWebDriver();
+ self::tearDownTestUsers();
+ self::setUpNoPermissionsUser();
+ self::deleteLoginTimeout();
+ }
+
+ public static function tearDownAfterClass()
+ {
+ parent::tearDownAfterClass();
+ self::$webDriver->quit();
+ self::tearDownTestUsers();
+ }
+
+ /**
+ * @throws \CDbException
+ */
+ private static function tearDownTestUsers(){
+ $noPermissionsUser = User::findByUsername(self::$noPermissionsUserUsername);
+ if($noPermissionsUser){
+ $noPermissionsUser->delete();
+ }
+ }
+ /**
+ * @throws \Exception
+ */
+ private static function setUpNoPermissionsUser(){
+ $user = new User();
+ $user->users_name =self::$noPermissionsUserUsername;
+ $user->email = 'no-permissions@example.com';
+ $user->full_name = 'Iha Veno Permissioons';
+ $user->setPassword(self::$noPermissionsUserPassword);
+ if($user->save()){
+ self::$noPermissionsUser = $user;
+ }else{
+ throw new \Exception('Could not create User: '.serialize($user->errors));
+ }
+ }
+
+ /**
+ * @throws \Exception
+ */
+ private static function setUpWebDriver(){
self::$webDriver = self::$testHelper->getWebDriver();
if (empty(self::$webDriver)) {
@@ -82,11 +124,6 @@ public static function setUpBeforeClass()
self::$testHelper->enablePreview();
}
- public static function tearDownAfterClass()
- {
- parent::tearDownAfterClass();
- self::$webDriver->quit();
- }
/**
* @param $url
diff --git a/tests/controllers/AdminViewsTest.php b/tests/controllers/AdminViewsTest.php
index dc7ec314d82..0722a64ece9 100644
--- a/tests/controllers/AdminViewsTest.php
+++ b/tests/controllers/AdminViewsTest.php
@@ -170,19 +170,22 @@ public function testAdminClickViews($name,$view){
$url = $this->getUrl($view);
$this->openView($url);
try{
+
self::$webDriver->wait(2)->until(
WebDriverExpectedCondition::presenceOfAllElementsLocatedBy(
WebDriverBy::id('set-user-permissions-'.self::$noPermissionsUser->primaryKey)
)
);
+
$clickable = self::$webDriver->findElement(WebDriverBy::id('set-user-permissions-'.self::$noPermissionsUser->primaryKey));
$clickable->click();
+ return $this->findViewTag($name,$view);
}catch (\Exception $e){
- throw $e;
$screenshot = self::$webDriver->takeScreenshot();
$filename = self::$screenshotsFolder .'/'.$name.'.png';
file_put_contents($filename, $screenshot);
+ throw $e;
}
}