function BpcDisplayTestCase::testSingleNodeCreation in Commerce Bulk Product Creation 7.2
Tests the automatic creation of a single display node.
File
- modules/
bpc_display/ bpc_display.test, line 108 - Tests for Commerce BPC display node creation
Class
- BpcDisplayTestCase
- @file Tests for Commerce BPC display node creation
Code
function testSingleNodeCreation() {
$this
->setDisplaySetting(array(
'creation_method' => 'auto',
'auto_node_title_pattern' => 'Title: [bulk_defaults:entered_title]',
'auto_content_type' => 'product_display',
));
$this
->drupalGet($this->bulkUrl);
$this
->assertNoText('Create Products and Create Display');
$this
->submitBulkForm();
// Default setting: We should be redirected to the product listing.
$this
->assertUrl('admin/commerce/products');
$this
->assertDisplayExists(array(
1,
2,
));
$this
->assertNoDisplayExists(array(
1,
));
$this
->assertNoDisplayExists(array(
2,
));
$nodes = $this
->findDisplaysFor(array(
1,
2,
));
$node = reset($nodes);
$this
->assertEqual($node->title, 'Title: ' . $this->params['title_fragment'], "The title of the auto-generated node is the token-replaced value of the corresponding setting.");
$this
->setDisplaySetting(array(
'auto_redirect' => 'display node',
));
$this
->submitBulkForm();
$this
->assertDisplayExists(array(
3,
4,
));
$this
->assertNoDisplayExists(array(
3,
));
$this
->assertNoDisplayExists(array(
4,
));
$nodes = $this
->findDisplaysFor(array(
3,
4,
));
$node = reset($nodes);
$this
->assertEqual($node->title, 'Title: ' . $this->params['title_fragment'], "The title of the auto-generated node is the token-replaced value of the corresponding setting.");
$nid = $node->nid;
$this
->assertUrl('node/' . $nid);
$this
->setDisplaySetting(array(
'auto_redirect' => 'custom',
'auto_redirect_custom' => 'admin/commerce',
));
$this
->submitBulkForm();
$this
->assertDisplayExists(array(
5,
6,
));
$this
->assertNoDisplayExists(array(
5,
));
$this
->assertNoDisplayExists(array(
6,
));
$this
->assertUrl('admin/commerce');
$this
->createDummyProductDisplayContentType('product_display2', TRUE, 'field_product', -1);
$this
->setDisplaySetting(array(
'auto_content_type' => 'product_display2',
));
$this
->submitBulkForm();
$this
->assertNoDisplayExists(array(
7,
8,
), 'product_display');
$this
->assertDisplayExists(array(
7,
8,
), 'product_display2');
}