Issue #1811804 by xjm: Provide a test page testing module.
parent
f50038f1ea
commit
195d2c9d5d
|
@ -19,7 +19,7 @@ class MenuNodeTest extends WebTestBase {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $modules = array('menu');
|
public static $modules = array('menu', 'test_page_test');
|
||||||
|
|
||||||
protected $profile = 'standard';
|
protected $profile = 'standard';
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ class MenuNodeTest extends WebTestBase {
|
||||||
$this->drupalPost('node/add/page', $edit, t('Save'));
|
$this->drupalPost('node/add/page', $edit, t('Save'));
|
||||||
$node = $this->drupalGetNodeByTitle($node_title);
|
$node = $this->drupalGetNodeByTitle($node_title);
|
||||||
// Assert that there is no link for the node.
|
// Assert that there is no link for the node.
|
||||||
$this->drupalGet('user');
|
$this->drupalGet('test-page');
|
||||||
$this->assertNoLink($node_title);
|
$this->assertNoLink($node_title);
|
||||||
|
|
||||||
// Edit the node, enable the menu link setting, but skip the link title.
|
// Edit the node, enable the menu link setting, but skip the link title.
|
||||||
|
@ -80,7 +80,7 @@ class MenuNodeTest extends WebTestBase {
|
||||||
);
|
);
|
||||||
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
||||||
// Assert that there is no link for the node.
|
// Assert that there is no link for the node.
|
||||||
$this->drupalGet('user');
|
$this->drupalGet('test-page');
|
||||||
$this->assertNoLink($node_title);
|
$this->assertNoLink($node_title);
|
||||||
|
|
||||||
// Edit the node and create a menu link.
|
// Edit the node and create a menu link.
|
||||||
|
@ -91,7 +91,7 @@ class MenuNodeTest extends WebTestBase {
|
||||||
);
|
);
|
||||||
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
||||||
// Assert that the link exists.
|
// Assert that the link exists.
|
||||||
$this->drupalGet('user');
|
$this->drupalGet('test-page');
|
||||||
$this->assertLink($node_title);
|
$this->assertLink($node_title);
|
||||||
|
|
||||||
$this->drupalGet('node/' . $node->nid . '/edit');
|
$this->drupalGet('node/' . $node->nid . '/edit');
|
||||||
|
@ -103,7 +103,7 @@ class MenuNodeTest extends WebTestBase {
|
||||||
);
|
);
|
||||||
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
||||||
// Assert that there is no link for the node.
|
// Assert that there is no link for the node.
|
||||||
$this->drupalGet('user');
|
$this->drupalGet('test-page');
|
||||||
$this->assertNoLink($node_title);
|
$this->assertNoLink($node_title);
|
||||||
|
|
||||||
// Add a menu link to the Management menu.
|
// Add a menu link to the Management menu.
|
||||||
|
|
|
@ -19,7 +19,7 @@ class NodeCreationTest extends NodeTestBase {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $modules = array('node_test_exception', 'dblog');
|
public static $modules = array('node_test_exception', 'dblog', 'test_page_test');
|
||||||
|
|
||||||
public static function getInfo() {
|
public static function getInfo() {
|
||||||
return array(
|
return array(
|
||||||
|
@ -100,10 +100,11 @@ class NodeCreationTest extends NodeTestBase {
|
||||||
* Create an unpublished node and confirm correct redirect behavior.
|
* Create an unpublished node and confirm correct redirect behavior.
|
||||||
*/
|
*/
|
||||||
function testUnpublishedNodeCreation() {
|
function testUnpublishedNodeCreation() {
|
||||||
|
// Set the front page to the test page.
|
||||||
|
config('system.site')->set('page.front', 'test-page')->save();
|
||||||
|
|
||||||
// Set "Basic page" content type to be unpublished by default.
|
// Set "Basic page" content type to be unpublished by default.
|
||||||
variable_set('node_options_page', array());
|
variable_set('node_options_page', array());
|
||||||
// Set the front page to the default "node" page.
|
|
||||||
config('system.site')->set('page.front', 'node')->save();
|
|
||||||
|
|
||||||
// Create a node.
|
// Create a node.
|
||||||
$edit = array();
|
$edit = array();
|
||||||
|
@ -112,6 +113,11 @@ class NodeCreationTest extends NodeTestBase {
|
||||||
$this->drupalPost('node/add/page', $edit, t('Save'));
|
$this->drupalPost('node/add/page', $edit, t('Save'));
|
||||||
|
|
||||||
// Check that the user was redirected to the home page.
|
// Check that the user was redirected to the home page.
|
||||||
$this->assertText(t('Welcome to Drupal'), 'The user is redirected to the home page.');
|
$this->assertUrl('');
|
||||||
|
$this->assertText(t('Test page text'));
|
||||||
|
|
||||||
|
// Confirm that the node was created.
|
||||||
|
$this->assertRaw(t('!post %title has been created.', array('!post' => 'Basic page', '%title' => $edit["title"])));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ class SimpleTestTest extends WebTestBase {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $modules = array('simpletest');
|
public static $modules = array('simpletest', 'test_page_test');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The results array that has been parsed by getTestResults().
|
* The results array that has been parsed by getTestResults().
|
||||||
|
@ -30,13 +30,6 @@ class SimpleTestTest extends WebTestBase {
|
||||||
*/
|
*/
|
||||||
protected $test_ids = array();
|
protected $test_ids = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* The administrative user account to use during testing.
|
|
||||||
*
|
|
||||||
* @var Drupal\user\User
|
|
||||||
*/
|
|
||||||
protected $admin_user;
|
|
||||||
|
|
||||||
public static function getInfo() {
|
public static function getInfo() {
|
||||||
return array(
|
return array(
|
||||||
'name' => 'SimpleTest functionality',
|
'name' => 'SimpleTest functionality',
|
||||||
|
@ -49,8 +42,7 @@ class SimpleTestTest extends WebTestBase {
|
||||||
if (!$this->inCURL()) {
|
if (!$this->inCURL()) {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
// Create and log in an admin user.
|
// Create and log in an admin user.
|
||||||
$this->admin_user = $this->drupalCreateUser(array('administer unit tests'));
|
$this->drupalLogin($this->drupalCreateUser(array('administer unit tests')));
|
||||||
$this->drupalLogin($this->admin_user);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
self::$modules = array('non_existent_module');
|
self::$modules = array('non_existent_module');
|
||||||
|
@ -64,11 +56,10 @@ class SimpleTestTest extends WebTestBase {
|
||||||
function testInternalBrowser() {
|
function testInternalBrowser() {
|
||||||
global $conf;
|
global $conf;
|
||||||
if (!$this->inCURL()) {
|
if (!$this->inCURL()) {
|
||||||
// Retrieve the user page and check its title and headers.
|
// Retrieve the test page and check its title and headers.
|
||||||
$this->drupalGet('user');
|
$this->drupalGet('test-page');
|
||||||
$this->assertTrue($this->drupalGetHeader('Date'), t('An HTTP header was received.'));
|
$this->assertTrue($this->drupalGetHeader('Date'), t('An HTTP header was received.'));
|
||||||
$this->assertTitle(t('@user | @site-name', array(
|
$this->assertTitle(t('Test page | @site-name', array(
|
||||||
'@user' => $this->admin_user->name,
|
|
||||||
'@site-name' => config('system.site')->get('name'),
|
'@site-name' => config('system.site')->get('name'),
|
||||||
)));
|
)));
|
||||||
$this->assertNoTitle('Foo');
|
$this->assertNoTitle('Foo');
|
||||||
|
|
|
@ -19,7 +19,7 @@ class PageCacheTest extends WebTestBase {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $modules = array('node', 'system_test');
|
public static $modules = array('test_page_test', 'system_test');
|
||||||
|
|
||||||
public static function getInfo() {
|
public static function getInfo() {
|
||||||
return array(
|
return array(
|
||||||
|
@ -34,7 +34,7 @@ class PageCacheTest extends WebTestBase {
|
||||||
|
|
||||||
config('system.site')
|
config('system.site')
|
||||||
->set('name', 'Drupal')
|
->set('name', 'Drupal')
|
||||||
->set('page.front', 'node')
|
->set('page.front', 'test-page')
|
||||||
->save();
|
->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ class PageCacheTest extends WebTestBase {
|
||||||
$this->drupalGet('');
|
$this->drupalGet('');
|
||||||
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
|
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
|
||||||
$this->assertFalse($this->drupalGetHeader('Content-Encoding'), 'A Content-Encoding header was not sent.');
|
$this->assertFalse($this->drupalGetHeader('Content-Encoding'), 'A Content-Encoding header was not sent.');
|
||||||
$this->assertTitle(t('Welcome to @site-name | @site-name', array('@site-name' => config('system.site')->get('name'))), 'Site title matches.');
|
$this->assertTitle(t('Test page | @site-name', array('@site-name' => config('system.site')->get('name'))), 'Site title matches.');
|
||||||
$this->assertRaw('</html>', 'Page was not compressed.');
|
$this->assertRaw('</html>', 'Page was not compressed.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ class HttpRequestTest extends WebTestBase {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $modules = array('system_test', 'language');
|
public static $modules = array('system_test', 'language', 'test_page_test');
|
||||||
|
|
||||||
public static function getInfo() {
|
public static function getInfo() {
|
||||||
return array(
|
return array(
|
||||||
|
@ -45,11 +45,11 @@ class HttpRequestTest extends WebTestBase {
|
||||||
$this->assertEqual($unable_to_parse->code, -1001, 'Returned with "-1001" error code.');
|
$this->assertEqual($unable_to_parse->code, -1001, 'Returned with "-1001" error code.');
|
||||||
$this->assertEqual($unable_to_parse->error, 'unable to parse URL', 'Returned with "unable to parse URL" error message.');
|
$this->assertEqual($unable_to_parse->error, 'unable to parse URL', 'Returned with "unable to parse URL" error message.');
|
||||||
|
|
||||||
// Fetch the user login page.
|
// Fetch the test page.
|
||||||
$result = drupal_http_request(url('user/login', array('absolute' => TRUE)));
|
$result = drupal_http_request(url('test-page', array('absolute' => TRUE)));
|
||||||
$this->assertEqual($result->code, 200, 'Fetched page successfully.');
|
$this->assertEqual($result->code, 200, 'Fetched page successfully.');
|
||||||
$this->drupalSetContent($result->data);
|
$this->drupalSetContent($result->data);
|
||||||
$this->assertTitle(t('Log in | @site-name', array('@site-name' => config('system.site')->get('name'))));
|
$this->assertTitle(t('Test page | @site-name', array('@site-name' => config('system.site')->get('name'))));
|
||||||
|
|
||||||
// Test that code and status message is returned.
|
// Test that code and status message is returned.
|
||||||
$result = drupal_http_request(url('pagedoesnotexist', array('absolute' => TRUE)));
|
$result = drupal_http_request(url('pagedoesnotexist', array('absolute' => TRUE)));
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
name = Test page
|
||||||
|
description = Provides a test page for automated tests.
|
||||||
|
package = Testing
|
||||||
|
version = VERSION
|
||||||
|
core = 8.x
|
||||||
|
hidden = TRUE
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_menu().
|
||||||
|
*/
|
||||||
|
function test_page_test_menu() {
|
||||||
|
$items['test-page'] = array(
|
||||||
|
'title' => 'Test front page',
|
||||||
|
'page callback' => 'test_page_test_page',
|
||||||
|
'access callback' => TRUE,
|
||||||
|
'type' => MENU_CALLBACK,
|
||||||
|
);
|
||||||
|
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Page callback: Returns a test page and sets the title.
|
||||||
|
*
|
||||||
|
* @see test_page_test_menu()
|
||||||
|
*/
|
||||||
|
function test_page_test_page() {
|
||||||
|
drupal_set_title(t('Test page'));
|
||||||
|
return t('Test page text.');
|
||||||
|
}
|
Loading…
Reference in New Issue