Skip to content

Commit

Permalink
click views
Browse files Browse the repository at this point in the history
  • Loading branch information
TonisOrmisson committed Dec 30, 2017
1 parent 064eb1d commit 2e6a3b5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 12 deletions.
2 changes: 1 addition & 1 deletion application/controllers/admin/useraction.php
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion application/models/User.php
Expand Up @@ -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 = "<button data-toggle='tooltip' data-user='".htmlspecialchars($this->full_name)."' data-url='".$setPermissionsUrl."' data-uid='".$this->uid."' data-action='setuserpermissions' title='".gT("Set global permissions for this user")."' type='submit' class='btn btn-default btn-xs action_usercontrol_button'><span class='icon-security text-success'></span></button>";
$setPermissionsUser = "<button id= 'set-user-permissions-{$this->primaryKey}' data-toggle='tooltip' data-user='".htmlspecialchars($this->full_name)."' data-url='".$setPermissionsUrl."' data-uid='".$this->uid."' data-action='setuserpermissions' title='".gT("Set global permissions for this user")."' type='submit' class='btn btn-default btn-xs action_usercontrol_button'><span class='icon-security text-success'></span></button>";
}
if ((Permission::model()->hasGlobalPermission('superadmin', 'read')
|| Permission::model()->hasGlobalPermission('templates', 'read'))
Expand Down
4 changes: 0 additions & 4 deletions tests/TestBaseClassView.php
Expand Up @@ -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(
Expand Down
47 changes: 42 additions & 5 deletions tests/TestBaseClassWeb.php
Expand Up @@ -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)) {
Expand All @@ -82,11 +124,6 @@ public static function setUpBeforeClass()
self::$testHelper->enablePreview();
}

public static function tearDownAfterClass()
{
parent::tearDownAfterClass();
self::$webDriver->quit();
}

/**
* @param $url
Expand Down
5 changes: 4 additions & 1 deletion tests/controllers/AdminViewsTest.php
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 2e6a3b5

Please sign in to comment.