public function SerialTestCase::testSerial in Serial Field 7
Create N nodes and attach N comments for the last.
Parameters
int $nodes: Number of nodes for creation.
int $comments: Number of comments for creation.
File
- tests/
serial.test, line 64 - Test Serial functionality.
Class
- SerialTestCase
- Class SerialTestCase.
Code
public function testSerial($nodes = 15, $comments = 6) {
for ($i = 0; $i < $nodes; $i++) {
// Open form for add new node.
$this
->visit('node/add/' . str_replace('_', '-', static::CONTENT_TYPE));
// Submit new node with filled title.
$this
->drupalPost(NULL, array(
'title' => "Node {$i}",
), t('Save'));
}
// Go to editing of the last created node.
$this
->visit("node/{$nodes}/edit");
// Check that last created node number equal to serial ID.
$this
->assertSerialField($nodes);
// Go to viewing of the last created node.
$this
->visit("node/{$nodes}");
// Post comments for last created node.
for ($i = 0; $i < $comments; $i++) {
$this
->drupalPost(NULL, array(
self::fieldName('comment_body') => "Comment {$i}",
), t('Save'));
}
// Go to editing of the last created comment.
$this
->visit("comment/{$comments}/edit");
// Ensure the last-posted comment number equal to serial ID.
$this
->assertSerialField($comments);
}