parent
726d72f94c
commit
14e277e030
|
|
@ -10,3 +10,4 @@ nginx-ssl.access.log
|
|||
nginx-ssl.error.log
|
||||
php-errors.log
|
||||
sftp-config.json
|
||||
selenium.php
|
||||
|
|
@ -35,7 +35,8 @@
|
|||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"tests/TestCase.php"
|
||||
"tests/TestCase.php",
|
||||
"tests/UiTestCase.php"
|
||||
]
|
||||
},
|
||||
"___scripts": {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
class UiTestCase extends PHPUnit_Extensions_SeleniumTestCase
|
||||
{
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
/*
|
||||
* Look for selenium configuration
|
||||
*/
|
||||
if (file_exists($seleniumEnv = __DIR__.'/../selenium.php'))
|
||||
require_once $seleniumEnv;
|
||||
|
||||
/*
|
||||
* Configure selenium
|
||||
*/
|
||||
if (!defined('TEST_SELENIUM_URL'))
|
||||
return $this->markTestSkipped('Selenium skipped');
|
||||
|
||||
if (defined('TEST_SELENIUM_HOST')) $this->setHost(TEST_SELENIUM_HOST);
|
||||
if (defined('TEST_SELENIUM_PORT')) $this->setPort(TEST_SELENIUM_PORT);
|
||||
if (defined('TEST_SELENIUM_BROWSER')) $this->setBrowser(TEST_SELENIUM_BROWSER);
|
||||
$this->setBrowserUrl(TEST_SELENIUM_URL);
|
||||
}
|
||||
|
||||
protected function signInToBackend()
|
||||
{
|
||||
$this->open('backend');
|
||||
$this->type("name=login", TEST_SELENIUM_USER);
|
||||
$this->type("name=password", TEST_SELENIUM_PASS);
|
||||
$this->click("//button[@type='submit']");
|
||||
$this->waitForPageToLoad("30000");
|
||||
}
|
||||
|
||||
protected function waitForElementPresent($target, $timeout = 120)
|
||||
{
|
||||
for ($second = 0; ; $second++) {
|
||||
if ($second >= $timeout)
|
||||
$this->fail("timeout");
|
||||
|
||||
try {
|
||||
if ($this->isElementPresent($target)) break;
|
||||
}
|
||||
catch (Exception $e) {}
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
class TemplateTest extends UiTestCase
|
||||
{
|
||||
|
||||
public function testOpenTemplates()
|
||||
{
|
||||
$this->signInToBackend();
|
||||
$this->open('cms');
|
||||
$this->waitForPageToLoad("30000");
|
||||
|
||||
// Fix the sidebar
|
||||
$this->click("xpath=(//a[@class='fix-button'])[1]");
|
||||
|
||||
// Create a new page
|
||||
$this->click("xpath=(//button[@data-control='create-template'])[1]");
|
||||
$this->waitForElementPresent("name=settings[title]");
|
||||
|
||||
// Populate page details
|
||||
$this->type('name=settings[title]', 'Functional Test Page');
|
||||
$this->type('name=settings[url]', '/xxx/functional/test/page');
|
||||
$this->type('name=fileName', 'xxx_functional_test_page');
|
||||
|
||||
// Save the new page
|
||||
$this->click("xpath=(//a[@data-request='onSave'])[1]");
|
||||
$this->waitForElementPresent("xpath=(//li[@data-tab-id='page-website-xxx_functional_test_page.htm'])[1]");
|
||||
|
||||
// Close the tab
|
||||
$this->click("xpath=(//li[@data-tab-id='page-website-xxx_functional_test_page.htm']/span[@class='tab-close'])[1]");
|
||||
|
||||
// Reopen the tab
|
||||
$this->waitForElementPresent("xpath=(//div[@id='TemplateList-pageList-template-list']/ul/li[@data-item-path='xxx_functional_test_page.htm']/a)[1]");
|
||||
$this->click("xpath=(//div[@id='TemplateList-pageList-template-list']/ul/li[@data-item-path='xxx_functional_test_page.htm']/a)[1]");
|
||||
$this->waitForElementPresent("name=settings[title]");
|
||||
|
||||
// Delete the page
|
||||
$this->click("xpath=(//button[@data-request='onDelete'])[1]");
|
||||
$this->assertTrue((bool)preg_match('/^Do you really want delete this page[\s\S]$/',$this->getConfirmation()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
class AuthTest extends UiTestCase
|
||||
{
|
||||
|
||||
// public function testSignInAndOut()
|
||||
// {
|
||||
// $this->open('backend');
|
||||
|
||||
// try {
|
||||
// $this->assertTitle('Administration Area');
|
||||
// $this->assertTrue($this->isElementPresent("name=login"));
|
||||
// $this->assertTrue($this->isElementPresent("name=password"));
|
||||
// $this->assertTrue($this->isElementPresent("//button[@type='submit']"));
|
||||
// $this->verifyText("//button[@type='submit']", "Login");
|
||||
// }
|
||||
// catch (PHPUnit_Framework_AssertionFailedError $e) {
|
||||
// array_push($this->verificationErrors, $e->toString());
|
||||
// }
|
||||
|
||||
// /*
|
||||
// * Sign in
|
||||
// */
|
||||
// $this->type("name=login", TEST_SELENIUM_USER);
|
||||
// $this->type("name=password", TEST_SELENIUM_PASS);
|
||||
// $this->click("//button[@type='submit']");
|
||||
// $this->waitForPageToLoad("30000");
|
||||
|
||||
// try {
|
||||
// $this->assertTitle('Dashboard | October CMS');
|
||||
// $this->assertTrue($this->isElementPresent('css=a[title="Sign out"]'));
|
||||
// }
|
||||
// catch (PHPUnit_Framework_AssertionFailedError $e) {
|
||||
// array_push($this->verificationErrors, $e->toString());
|
||||
// }
|
||||
|
||||
// /*
|
||||
// * Log out
|
||||
// */
|
||||
// $this->click('css=a[title="Sign out"]');
|
||||
// $this->waitForPageToLoad("30000");
|
||||
|
||||
// try {
|
||||
// $this->assertTitle('Administration Area');
|
||||
// }
|
||||
// catch (PHPUnit_Framework_AssertionFailedError $e) {
|
||||
// array_push($this->verificationErrors, $e->toString());
|
||||
// }
|
||||
// }
|
||||
|
||||
// public function testPasswordReset()
|
||||
// {
|
||||
// $this->open('backend');
|
||||
|
||||
// try {
|
||||
// $this->assertTrue($this->isElementPresent("link=exact:Forgot your password?"));
|
||||
// }
|
||||
// catch (PHPUnit_Framework_AssertionFailedError $e) {
|
||||
// array_push($this->verificationErrors, $e->toString());
|
||||
// }
|
||||
|
||||
// $this->click('link=exact:Forgot your password?');
|
||||
// $this->waitForPageToLoad("30000");
|
||||
|
||||
// try {
|
||||
// $this->assertTrue($this->isElementPresent("//button[@type='submit']"));
|
||||
// $this->verifyText("//button[@type='submit']", "Restore");
|
||||
// $this->assertTrue($this->isElementPresent("link=Cancel"));
|
||||
// }
|
||||
// catch (PHPUnit_Framework_AssertionFailedError $e) {
|
||||
// array_push($this->verificationErrors, $e->toString());
|
||||
// }
|
||||
|
||||
// $this->type("name=login", TEST_SELENIUM_USER);
|
||||
// sleep(1);
|
||||
// $this->click("//button[@type='submit']");
|
||||
// $this->waitForPageToLoad("30000");
|
||||
|
||||
// try {
|
||||
// $this->assertTitle('Administration Area');
|
||||
// $this->assertTrue($this->isElementPresent("css=p.flash-message.success"));
|
||||
// $this->verifyText("css=p.flash-message.success", "An email has been sent to your email address with password restore instructions.×");
|
||||
// }
|
||||
// catch (PHPUnit_Framework_AssertionFailedError $e) {
|
||||
// array_push($this->verificationErrors, $e->toString());
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ class CmsExceptionTest extends TestCase
|
|||
$router = new Router($theme);
|
||||
$page = $router->findByUrl('/throw-php');
|
||||
|
||||
$foreignException = new \Symfony\Component\Debug\Exception\FatalErrorException('This is a general error');
|
||||
$foreignException = new \Symfony\Component\Debug\Exception\FatalErrorException('This is a general error', 100, 1, 'test.php', 20);
|
||||
$this->setProtectedProperty($foreignException, 'file', "/modules/cms/classes/CodeParser.php(165) : eval()'d code line 7");
|
||||
|
||||
$exception = new CmsException($page, 300);
|
||||
|
|
@ -301,7 +301,7 @@ ESC;
|
|||
|
||||
public function testComponentAliases()
|
||||
{
|
||||
include_once dirname(dirname(__DIR__)) . '/fixtures/System/plugins/October/Test/Components/Archive.php';
|
||||
include_once base_path() . '/tests/fixtures/System/plugins/October/Test/Components/Archive.php';
|
||||
|
||||
$theme = new Theme();
|
||||
$theme->load('test');
|
||||
Loading…
Reference in New Issue