public function CommerceNodeCheckoutBaseTest::createPage in Commerce Node Checkout 7
Create a basic page node.
Parameters
$values: Additional array to merge in to the edit parameter.
Return value
The node that was created, otherwise NULL if an error occurred.
2 calls to CommerceNodeCheckoutBaseTest::createPage()
- CommerceNodeCheckoutExpireTests::testCommerceNodeCheckoutExpire in commerce_node_checkout_expire/
commerce_node_checkout_expire.test - Test everything we need to do with content, expiration, notifications, etc.
- CommerceNodeCheckoutTests::testAnonymousPublishing in ./
commerce_node_checkout.test - Test anonymous users can create content after payment.
File
- ./
commerce_node_checkout.test, line 198 - Provides tests for Commerce Node Checkout process.
Class
- CommerceNodeCheckoutBaseTest
- Base class for other test classes to extend.
Code
public function createPage($values = array()) {
// Go to the node form
$this
->drupalGet('node/add/page');
// Build the node
$edit = $values + array(
'title' => 'Miniature pony',
'body[und][0][value]' => 'A lovely 3yo miniature pony named rainbow sparkles',
);
// Save the node by posting to the current url.
$this
->drupalPost(NULL, $edit, t('Save'));
// Assert we get the required messages.
$status = $this
->assertText(format_string('Basic page @title has been created', array(
'@title' => $edit['title'],
)), 'Created the page');
// Load the node, if it was created successfully
$node = $status ? $this
->loadLastNode() : NULL;
// Check if the 'Don't add to the shopping cart' checkbox was not checked
// was checked
if (!isset($edit['commerce_node_checkout_skip']) || $edit['commerce_node_checkout_skip'] == 0) {
// Make sure the node isn't published.
$this
->assertFalse((bool) $node->status, 'The node is not published');
// Check that the line item was added to the cart
$this
->assertText('Standard listing added to your cart', 'Listing item added to cart');
// Check that the user made it to the cart
$this
->assertTrue($this
->isPath('cart'), 'User redirected to shopping cart');
}
else {
// Check that we're now viewing the node instead of the cart
$this
->assertTrue(strstr($this
->getUrl(), 'node'), 'User skipped the shopping cart after node creation (admin-only)');
}
return $node;
}