123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731 |
- <?php
- /**
- * @file
- * Unit tests for Publish Content module.
- */
- /**
- * We test to ensure we are not messing up with the default Drupal
- * access for view node i.e. a owner of a node can view it even if unpublished.
- */
- abstract class PublishContentWebTestBase extends DrupalWebTestCase {
- /**
- * Perform a GET operation on a node.
- *
- * This will check the response to access some operation via
- * the URL of a node. In the case of 'publish' or 'unpublish'
- * it will first visit the view of a node so that the relevant
- * tabs can be generated.
- *
- * @param int $nid
- * The node nid
- * @param string $op
- * An operation such as 'view', 'edit', 'publish', 'unpublish'
- * @param int $expected_response
- * The expexted response code. If the user should not be able to
- * see the 'publish' or 'unpublish' tabs, set this to 403, otherwise
- * 200.
- * @param string $msg
- * (optional) An assertion log message.
- */
- public abstract function assertNodeOperationAccess($nid, $op, $expected_response, $msg = '');
- /**
- * Allow content type to be used with publish content.
- */
- public function enablePublishContentForContentType($types) {
- if (!is_array($types)) {
- $types = array($types);
- }
- foreach ($types as $type) {
- variable_set('publishcontent_' . $type, TRUE);
- }
- // Rebuild SimpleTests permissions cache.
- $this->checkPermissions(array(), TRUE);
- }
- /**
- * Assert the status of a given node.
- *
- * @param int $nid
- * The node nid to check
- * @param int $status
- * Either 1 for published or 0 for unpublished
- */
- public function assertNodeStatus($nid, $status, $msg = '') {
- $node = node_load($nid, NULL, TRUE);
- $msg = !empty($msg) ? $msg : t('Node status is @actual, expecting @expected', array('@actual' => $node->status, '@expected' => $status));
- $this->assertEqual($node->status, $status, $msg);
- }
- /**
- * Set the status of a node.
- *
- * @param node|int $node
- * A loaded node object or node nid
- * @param int $status
- * The status to set, 1 for published, 0 for unpublished.
- */
- public function setNodeStatus($node, $status, $msg = '') {
- $node = is_object($node) ? $node : node_load($node);
- if ($node->status != $status) {
- $node->status = $status;
- node_save($node);
- }
- }
- /**
- * Check the current user session forbids publish of a given node.
- *
- * @param node $node
- * The node object to test against.
- */
- public function assertCurrentUserCannotPublish($node) {
- $status = $node->status;
- $username = $this->loggedInUser->name;
- $this->setNodeStatus($node, 1, 'Start test with a published node');
- $this->assertNodeOperationAccess($node->nid, 'publish', 403, $username . ' cannot publish the published node');
- $this->assertNodeStatus($node->nid, 1, 'node should be still published');
- $this->assertNodeOperationAccess($node->nid, 'view', 200, $username . ' can view the published node');
- $this->setNodeStatus($node, 0);
- $this->assertNodeOperationAccess($node->nid, 'publish', 403, $username . ' cannot publish the unpublished node');
- $this->assertNodeStatus($node->nid, 0, 'node should be still unpublished');
- $this->setNodeStatus($node, $status, 'Reset the nodes status');
- }
- /**
- * Check the current user session cannot unpublish a given node.
- *
- * @param node $node
- * The node object to test against.
- */
- public function assertCurrentUserCannotUnpublish($node) {
- $status = $node->status;
- $username = $this->loggedInUser->name;
- $this->setNodeStatus($node, 1, 'Start test with a published node');
- $this->assertNodeOperationAccess($node->nid, 'unpublish', 403, $username . ' cannot unpublish the published node');
- $this->assertNodeStatus($node->nid, 1, 'node should be still published');
- $this->assertNodeOperationAccess($node->nid, 'view', 200, $username . ' can view the published node');
- $this->setNodeStatus($node, 0);
- $this->assertNodeOperationAccess($node->nid, 'unpublish', 403, $username . ' cannot unpublish an unpublished node');
- $this->assertNodeStatus($node->nid, 0, 'node should be still unpublished');
- $this->setNodeStatus($node, $status, 'Reset the nodes status');
- }
- /**
- * Check the current user session can publish a given node.
- *
- * @param node $node
- * The node object to test against.
- */
- public function assertCurrentUserCanPublish($node) {
- $status = $node->status;
- $username = $this->loggedInUser->name;
- $this->setNodeStatus($node, 1, 'Start test with a published node');
- $this->assertNodeOperationAccess($node->nid, 'publish', 403, $username . ' cannot access the publish callback for a node which is already published.');
- $this->assertNodeOperationAccess($node->nid, 'view', 200, $username . ' can view the published node');
- $this->setNodeStatus($node, 0);
- $this->assertNodeOperationAccess($node->nid, 'view', 200, $username . ' can view unpublished node');
- $this->assertNodeOperationAccess($node->nid, 'publish', 200, $username . ' can access publish callback on an unpublished node');
- $this->assertNodeStatus($node->nid, 1, 'node should now be published');
- $this->setNodeStatus($node, $status, 'Reset the nodes status');
- }
- /**
- * Check the current user session can unpublish a node.
- *
- * @param node $node
- * The node to test against.
- */
- public function assertCurrentUserCanUnpublish($node) {
- $status = $node->status;
- $username = $this->loggedInUser->name;
- $this->setNodeStatus($node, 1, 'Start test with a published node');
- $this->assertNodeOperationAccess($node->nid, 'unpublish', 200, $username . ' can access unpublish callback on a published node');
- $this->assertNodeStatus($node->nid, 0, 'Node should now be unpublished');
- $this->assertNodeOperationAccess($node->nid, 'view', 200, $username . ' can view the unpublished node.');
- $this->assertNodeOperationAccess($node->nid, 'unpublish', 403, $username . ' cannot access the unpublish callback of an unpublished node');
- $this->assertNodeStatus($node->nid, 0, 'Node should still be unpublished');
- $this->setNodeStatus($node, $status, 'Reset the nodes status');
- }
- /**
- * Assert the current user can publish a node from the listing test page.
- */
- public function assertCanPublishFromLinksPage($node) {
- $status = $node->status;
- $this->setNodeStatus($node, 0, 'Start test with an unpublished node');
- $this->drupalGet('publishcontent-links');
- $this->assertResponse(200);
- $this->assertLink('publish-' . $node->nid);
- $this->assertNoLink('unpublish-' . $node->nid);
- $this->clickLink('publish-' . $node->nid);
- $this->assertResponse(200);
- $this->assertNodeStatus($node->nid, 1);
- $this->setNodeStatus($node, $status, 'Reset status');
- }
- /**
- * Assert the current user cannot publish a node from the listing test page.
- */
- public function assertCannotPublishFromLinksPage($node) {
- $status = $node->status;
- $this->setNodeStatus($node, 0, 'Start test with an unpublished node');
- $this->drupalGet('publishcontent-links');
- $this->assertResponse(200);
- $this->assertNoLink('publish-' . $node->nid);
- $this->assertNoLink('unpublish-' . $node->nid);
- $this->setNodeStatus($node, $status, 'Reset status');
- }
- /**
- * Assert the current user can unpublish a node from the listing test page.
- */
- public function assertCanUnpublishFromLinksPage($node) {
- $status = $node->status;
- $this->setNodeStatus($node, 1, 'Start test with a published node');
- $this->drupalGet('publishcontent-links');
- $this->assertResponse(200);
- $this->assertLink('unpublish-' . $node->nid);
- $this->assertNoLink('publish-' . $node->nid);
- $this->clickLink('unpublish-' . $node->nid);
- $this->assertResponse(200);
- $this->assertNodeStatus($node->nid, 0);
- $this->setNodeStatus($node, $status, 'Reset status');
- }
- /**
- * Assert the current user cannot unpublish a node from the listing test page.
- */
- public function assertCannotUnpublishFromLinksPage($node) {
- $status = $node->status;
- $this->setNodeStatus($node, 1, 'Start test with a published node');
- $this->drupalGet('publishcontent-links');
- $this->assertResponse(200);
- $this->assertNoLink('publish-' . $node->nid);
- $this->assertNoLink('unpublish-' . $node->nid);
- $this->setNodeStatus($node, $status, 'Reset status');
- }
- /**
- * Check no publish permission by node owner.
- */
- public function testNoPublishPermissionByOwner() {
- $web_user = $this->drupalCreateUser(array('access content'));
- $this->drupalLogin($web_user);
- $node = $this->drupalCreateNode(
- array(
- 'type' => 'page',
- 'uid' => $web_user->uid,
- 'status' => 1,
- )
- );
- $this->assertCurrentUserCannotPublish($node);
- $this->assertCurrentUserCannotUnpublish($node);
- $this->setNodeStatus($node, 0);
- $this->assertNodeOperationAccess($node->nid, 'view', 403, 'Node is not accessible by its owner when unpublished.');
- }
- /**
- * Check publishcontent module does not interfere with the normal Drupal.
- */
- public function testNoPermissionAndNotOwner() {
- $node = $this->drupalCreateNode(
- array(
- 'type' => 'page',
- 'uid' => 0,
- 'status' => 1,
- )
- );
- $this->drupalLogin($this->drupalCreateUser(array('access content')));
- $this->assertCurrentUserCannotPublish($node);
- $this->assertCurrentUserCannotUnpublish($node);
- $this->setNodeStatus($node, 0);
- $this->assertNodeOperationAccess($node->nid, 'view', 403, 'Node is not viewable by non owner when unpublished by a user without publish or unpublish permissions');
- }
- /**
- * Test the combination of publish but not unpublish permissions.
- */
- public function testPublishNotUnpublish() {
- $type = 'page';
- $this->enablePublishContentForContentType($type);
- $web_user = $this->drupalCreateUser(array(
- 'access content',
- 'publish editable ' . $type . ' content',
- 'view own unpublished content',
- 'edit own ' . $type . ' content',
- ));
- $this->drupalLogin($web_user);
- $node = $this->drupalCreateNode(
- array(
- 'type' => $type,
- 'uid' => $web_user->uid,
- 'status' => 0,
- )
- );
- $this->drupalGet('node/' . $node->nid . '/edit');
- $this->assertResponse(200);
- $this->assertCurrentUserCanPublish($node);
- $this->assertCurrentUserCannotUnpublish($node);
- }
- /**
- * Test the combination of unpublish but not publish.
- */
- public function testNotPublishUnpublish() {
- $type = 'page';
- $this->enablePublishContentForContentType($type);
- $web_user = $this->drupalCreateUser(array(
- 'access content',
- 'unpublish any ' . $type . ' content',
- 'view own unpublished content',
- 'edit own ' . $type . ' content',
- ));
- $this->drupalLogin($web_user);
- $node = $this->drupalCreateNode(
- array(
- 'type' => $type,
- 'uid' => $web_user->uid,
- 'status' => 1,
- )
- );
- $this->assertCurrentUserCannotPublish($node);
- $this->assertCurrentUserCanUnpublish($node);
- }
- /**
- * Test the combination of both publish and unpublish.
- */
- public function testPublishUnpublish() {
- $type = 'page';
- $this->enablePublishContentForContentType($type);
- $web_user_1 = $this->drupalCreateUser(array(
- 'access content',
- 'view own unpublished content',
- 'edit any ' . $type . ' content',
- 'publish any content',
- ));
- $node1 = $this->drupalCreateNode(
- array(
- 'type' => $type,
- 'uid' => $web_user_1->uid,
- 'status' => 1,
- )
- );
- $this->drupalLogin($web_user_1);
- $this->assertCurrentUserCanPublish($node1);
- $this->assertCurrentUserCannotUnpublish($node1);
- $web_user_2 = $this->drupalCreateUser(array(
- 'access content',
- 'view own unpublished content',
- 'edit any ' . $type . ' content',
- 'unpublish any content',
- ));
- $node2 = $this->drupalCreateNode(
- array(
- 'type' => $type,
- 'uid' => $web_user_2->uid,
- 'status' => 1,
- )
- );
- $this->drupalLogin($web_user_2);
- $this->assertCurrentUserCannotPublish($node2);
- $this->assertCurrentUserCanUnpublish($node2);
- $web_user_3 = $this->drupalCreateUser(array(
- 'access content',
- 'view own unpublished content',
- 'edit any ' . $type . ' content',
- 'publish any content',
- 'unpublish any content',
- ));
- $node3 = $this->drupalCreateNode(
- array(
- 'type' => $type,
- 'uid' => $web_user_3->uid,
- 'status' => 1,
- )
- );
- $this->drupalLogin($web_user_3);
- $this->assertCurrentUserCanPublish($node3);
- $this->assertCurrentUserCanUnpublish($node3);
- }
- /**
- * Test basic publish ability using the publishcontent_test module.
- */
- public function testBasicPublishCallback() {
- $type = 'page';
- $this->enablePublishContentForContentType(array($type, 'article'));
- $web_user_1 = $this->drupalCreateUser(array(
- 'access content',
- 'publish any content',
- ));
- $web_user_2 = $this->drupalCreateUser(array(
- 'access content',
- 'unpublish any content',
- ));
- $web_user_3 = $this->drupalCreateUser(array(
- 'access content',
- 'publish any content',
- 'unpublish any content',
- ));
- $web_user_4 = $this->drupalCreateUser(array(
- 'access content',
- 'publish any ' . $type . ' content',
- ));
- $web_user_5 = $this->drupalCreateUser(array(
- 'access content',
- 'unpublish any ' . $type . ' content',
- ));
- $web_user_6 = $this->drupalCreateUser(array(
- 'access content',
- 'publish any ' . $type . ' content',
- 'unpublish any ' . $type . ' content',
- ));
- $web_user_7 = $this->drupalCreateUser(array(
- 'access content',
- 'publish any article content',
- 'unpublish any article content',
- ));
- $node = $this->drupalCreateNode(
- array(
- 'type' => $type,
- 'uid' => 1,
- 'status' => 0,
- )
- );
- $this->drupalLogin($web_user_1);
- $this->assertCanPublishFromLinksPage($node, 'Someone with publish any content can publish page node');
- $this->assertCannotUnpublishFromLinksPage($node, 'Someone with publish any content cannot unpublish page node');
- $this->drupalLogin($web_user_2);
- $this->assertCannotPublishFromLinksPage($node, 'Someone with unpublish any content cannot publish page node');
- $this->assertCanUnpublishFromLinksPage($node, 'Someone with unpublish any content can unpublish page node');
- $this->drupalLogin($web_user_3);
- $this->assertCanPublishFromLinksPage($node, 'Someone with publish and unpublish any content can publish page node');
- $this->assertCanUnpublishFromLinksPage($node, 'Someone with publish and unpublish any content can unpublish page node');
- $this->drupalLogin($web_user_4);
- $this->assertCanPublishFromLinksPage($node, 'Someone with publish any page nodes can publish a page node');
- $this->assertCannotUnpublishFromLinksPage($node, 'Someone with publish any page nodes cannot unpublish page node');
- $this->drupalLogin($web_user_5);
- $this->assertCannotPublishFromLinksPage($node, 'Someone with unpublish any page node cannot publish a page node');
- $this->assertCanUnpublishFromLinksPage($node, 'Someone with unpublish any page node can unpublish a page node');
- $this->drupalLogin($web_user_6);
- $this->assertCanPublishFromLinksPage($node, 'Someone with publish and unpublish any page node can publish a page node');
- $this->assertCanUnpublishFromLinksPage($node, 'Someone with publish and unpublish any page node can unpublish a page node');
- $this->drupalLogin($web_user_7);
- $this->assertCannotPublishFromLinksPage($node, 'Someone with publish any article content cannot publish page content');
- $this->assertCannotUnpublishFromLinksPage($node, 'Someone with unpublish any article content cannot unpublish page content');
- }
- }
- /**
- * Test permissions with the tab method.
- */
- class PublishContentTabTests extends PublishContentWebTestBase {
- /**
- * Drupal SimpleTest method: return metadata about the test.
- */
- public static function getInfo() {
- return array(
- 'name' => t('Publish Content: Tab Tests'),
- 'description' => t('Executes test suite for Publish Content module with the tab method.'),
- 'group' => t('Publish Content'),
- );
- }
- /**
- * Test setup instructions.
- */
- public function setUp() {
- parent::setUp('publishcontent', 'publishcontent_test');
- variable_set('publishcontent_method', PUBLISHCONTENT_METHOD_TABS);
- }
- /**
- * Perform a GET operation on a node.
- *
- * This will check the response to access some operation via
- * the URL of a node. In the case of 'publish' or 'unpublish'
- * it will first visit the view of a node so that the relevant
- * tabs can be generated.
- *
- * @param int $nid
- * The node nid
- * @param string $op
- * An operation such as 'view', 'edit', 'publish', 'unpublish'
- * @param int $expected_response
- * The expexted response code. If the user should not be able to
- * see the 'publish' or 'unpublish' tabs, set this to 403, otherwise
- * 200.
- * @param string $msg
- * (optional) An assertion log message.
- */
- public function assertNodeOperationAccess($nid, $op, $expected_response, $msg = '') {
- if (in_array($op, array('publish', 'unpublish'))) {
- $tab_link_text = ucfirst($op);
- // Visit the edit page first to generate the tab.
- $this->drupalGet("node/{$nid}");
- $view_response = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
- if ($view_response != 200) {
- $msg .= t('Could not view the node. Response code: @response', array('@response' => $view_response));
- $this->assert($expected_response == $view_response, $msg);
- return;
- }
- // Check the tab exists.
- $links = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $tab_link_text));
- if (!isset($links[0])) {
- // No tab.
- $msg .= t('Could not find a tab called @tab', array('@tab' => $tab_link_text));
- $this->assert($expected_response != 200, $msg);
- return;
- }
- // Now visit the tab.
- $this->clickLink($tab_link_text);
- $node = node_load($nid);
- if ($op == 'publish') {
- $this->assertText(_publishcontent_get_message($node->nid, $node->title, TRUE),
- 'Publish content message is visible.');
- }
- else {
- $this->assertText(_publishcontent_get_message($node->nid, $node->title, FALSE),
- 'Unpublish message is visible.');
- }
- }
- else {
- $url = $op == 'view' ? "node/{$nid}" : "node/$nid/$op";
- $this->drupalGet($url);
- }
- $this->assertResponse($expected_response, $msg);
- }
- }
- /**
- * Test permissions with the button method.
- */
- class PublishContentButtonTests extends PublishContentWebTestBase {
- /**
- * Drupal SimpleTest method: return metadata about the test.
- */
- public static function getInfo() {
- return array(
- 'name' => t('Publish Content: Button Tests'),
- 'description' => t('Executes test suite for Publish Content module with the button method.'),
- 'group' => t('Publish Content'),
- );
- }
- /**
- * Test setup instructions.
- */
- public function setUp() {
- parent::setUp('publishcontent', 'publishcontent_test');
- variable_set('publishcontent_method', PUBLISHCONTENT_METHOD_BUTTON);
- }
- /**
- * Perform a GET operation on a node.
- *
- * This will check the response to access some operation via
- * the URL of a node. In the case of 'publish' or 'unpublish'
- * it will first visit the view of a node so that the relevant
- * tabs can be generated.
- *
- * @param int $nid
- * The node nid
- * @param string $op
- * An operation such as 'view', 'edit', 'publish', 'unpublish'
- * @param int $expected_response
- * The expexted response code. If the user should not be able to
- * see the 'publish' or 'unpublish' tabs, set this to 403, otherwise
- * 200.
- * @param string $msg
- * (optional) An assertion log message.
- */
- public function assertNodeOperationAccess($nid, $op, $expected_response, $msg = '') {
- if (in_array($op, array('publish', 'unpublish'))) {
- $button_text = t(ucfirst($op));
- // Visit the edit page first to generate the tab.
- $this->drupalGet("node/{$nid}/edit");
- $view_response = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
- if ($view_response != 200) {
- $msg .= t('Could not view the node. Response code: @response', array('@response' => $view_response));
- $this->assert($expected_response == $view_response, $msg);
- return;
- }
- // Find the button.
- $buttons = $this->xpath('//input[@value=:label]', array(':label' => $button_text));
- if (!isset($buttons[0])) {
- // No button.
- $msg .= t('Could not find a button called @button', array('@button' => $button_text));
- $this->assert($expected_response != 200, $msg);
- return;
- }
- // Submit the form.
- $this->drupalPost("node/{$nid}/edit", array(), $button_text);
- }
- else {
- $url = $op == 'view' ? "node/{$nid}" : "node/$nid/$op";
- $this->drupalGet($url);
- }
- $this->assertResponse($expected_response, $msg);
- }
- }
- /**
- * Test permissions with the tab method.
- */
- class PublishContentCheckboxTests extends PublishContentWebTestBase {
- /**
- * Drupal SimpleTest method: return metadata about the test.
- */
- public static function getInfo() {
- return array(
- 'name' => t('Publish Content: Checkbox Tests'),
- 'description' => t('Executes test suite for Publish Content module with the checkbox method.'),
- 'group' => t('Publish Content'),
- );
- }
- /**
- * Test setup instructions.
- */
- public function setUp() {
- parent::setUp('publishcontent', 'publishcontent_test');
- variable_set('publishcontent_method', PUBLISHCONTENT_METHOD_NONE);
- }
- /**
- * Perform a GET operation on a node.
- *
- * This will check the response to access some operation via
- * the URL of a node. In the case of 'publish' or 'unpublish'
- * it will first visit the view of a node so that the relevant
- * tabs can be generated.
- *
- * @param int $nid
- * The node nid
- * @param string $op
- * An operation such as 'view', 'edit', 'publish', 'unpublish'
- * @param int $expected_response
- * The expexted response code. If the user should not be able to
- * see the 'publish' or 'unpublish' tabs, set this to 403, otherwise
- * 200.
- * @param string $msg
- * (optional) An assertion log message.
- */
- public function assertNodeOperationAccess($nid, $op, $expected_response, $msg = '') {
- if (in_array($op, array('publish', 'unpublish'))) {
- // Visit the edit page first to check for the published checkbox.
- $this->drupalGet("node/{$nid}/edit");
- $view_response = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
- if ($view_response != 200) {
- $msg .= t('Could not edit the node. Response code: @response', array('@response' => $view_response));
- $this->assert($expected_response == $view_response, $msg);
- return;
- }
- // Check the checkbox exists.
- $elements = $this->xpath('//input[@id=:id]', array(':id' => 'edit-status'));
- if (!isset($elements[0])) {
- // No checkboxes.
- $msg .= t('Published status checkbox is not accessible.');
- $this->assert($expected_response != 200, $msg);
- return;
- }
- // At this point the response code for checkboxes is irrelevant, if
- // they can access the edit page and see the checkbox, they can edit it.
- $expected_response = 200;
- // Tick or untick the published checkbox and submit the form.
- $edit_status = ($op == 'publish');
- $this->drupalPost("node/{$nid}/edit", array('status' => $edit_status), t('Save'));
- }
- else {
- $url = $op == 'view' ? "node/{$nid}" : "node/$nid/$op";
- $this->drupalGet($url);
- }
- $this->assertResponse($expected_response, $msg);
- }
- /**
- * Test access to the node add page is working.
- */
- public function testAccessNodeAdd() {
- $type = 'page';
- $this->enablePublishContentForContentType($type);
- $web_user_1 = $this->drupalCreateUser(array(
- 'access content',
- 'view own unpublished content',
- 'create ' . $type . ' content',
- 'publish editable content',
- 'unpublish editable content',
- ));
- $this->drupalLogin($web_user_1);
- $this->drupalGet('node/add/' . $type);
- $this->assertResponse(200);
- $this->assertFieldChecked('edit-status', t('Ensure the publish checkbox is available.'));
- }
- }
|