Skip to content

Commit

Permalink
test createsurveytest
Browse files Browse the repository at this point in the history
  • Loading branch information
TonisOrmisson committed Dec 30, 2017
1 parent 67131d1 commit 8619e5e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 55 deletions.
14 changes: 0 additions & 14 deletions application/models/TemplateConfiguration.php
@@ -1,18 +1,4 @@
<?php
if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}
/*
* LimeSurvey
* Copyright (C) 2007-2015 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

/**
* This is the model class for table "{{template_configuration}}".
Expand Down
40 changes: 0 additions & 40 deletions tests/TestBaseClassView.php
Expand Up @@ -41,44 +41,4 @@ public static function setupBeforeClass()
self::adminLogin($username, $password);
}

/**
* @param $name
* @param $view
* @throws \Exception
*/
protected function openAndFindViewTag($name, $view){
$this->url = $this->getUrl($view);
$this->openView($this->url);
return $this->findViewTag($name,$view);
}

/**
* @param string $name
* @param array $view
* @throws \Exception
*/
protected function findViewTag($name, $view)
{
$filename = self::$screenshotsFolder. '/'.$name.'.png';
$element = null;
try {
$element = self::find(WebDriverBy::id('action::' . $name));
} catch (\Exception $e) {
//throw new Exception($e->getMessage());
$screenshot = self::$webDriver->takeScreenshot();
file_put_contents($filename, $screenshot);
}
//$body = $this->webDriver->findElement(WebDriverBy::tagName('body'));
//var_dump($body->getText());
$this->assertNotEmpty(
$element,
'Possible screenshot at ' . $filename . PHP_EOL .
sprintf(
'FAILED viewing %s on route %s, full url %s',
$name,
$view['route'],
$this->url
)
);
}
}
41 changes: 41 additions & 0 deletions tests/TestBaseClassWeb.php
Expand Up @@ -280,4 +280,45 @@ protected static function find($selector,$waitSecondsUntil = 1){
}

}
/**
* @param $name
* @param $view
* @throws \Exception
*/
protected function openAndFindViewTag($name, $view){
$this->url = $this->getUrl($view);
$this->openView($this->url);
return $this->findViewTag($name,$view);
}

/**
* @param string $name
* @param array $view
* @throws \Exception
*/
protected function findViewTag($name, $view=[])
{
$filename = self::$screenshotsFolder. '/'.$name.'.png';
$element = null;
try {
$element = self::find(WebDriverBy::id('action::' . $name));
} catch (\Exception $e) {
//throw new Exception($e->getMessage());
$screenshot = self::$webDriver->takeScreenshot();
file_put_contents($filename, $screenshot);
}
//$body = $this->webDriver->findElement(WebDriverBy::tagName('body'));
//var_dump($body->getText());
$this->assertNotEmpty(
$element,
'Possible screenshot at ' . $filename . PHP_EOL .
sprintf(
'FAILED viewing %s on route %s, full url %s',
$name,
(isset($view['route'])?$view['route']:''),
$this->url
)
);
}

}
2 changes: 1 addition & 1 deletion tests/controllers/CreateSurveyTest.php
Expand Up @@ -96,7 +96,7 @@ public function testCreateSurvey()
self::findAndClick(WebDriverBy::id('save-form-button'));

// find the survey summary page tag
$element = self::find(WebDriverBy::id('action::surveySummay'));
$element = self::findViewTag('action::surveySummay');
$this->assertNotEmpty($element,'FAILED creating new survey');


Expand Down

0 comments on commit 8619e5e

Please sign in to comment.