function NodesInBlockTestCase::testNodeSubmissions in Nodes In Block 7
Test submitting of nodes and see if they appear in blocks and how they are rendered.
File
- ./
nodesinblock.test, line 101 - Tests for Nodes in block
Class
- NodesInBlockTestCase
- @file Tests for Nodes in block
Code
function testNodeSubmissions() {
$this
->_setNodesinblockConfiguration();
// Create an article on the front page.
$this
->_createNode('article', 1, '', '', FALSE);
// Created a first node.
$this
->_createNode('page', 2);
$this
->assertRaw('Nodes in block 1', 'Nodes in block 1 queue found');
// Should show up everywhere.
$this
->drupalGet('user');
$this
->assertRaw('Text 2', 'Title 2 node found');
$this
->drupalGet('node');
$this
->assertRaw('Text 2', 'Title 2 node found');
// Update node to show only up on frontpage.
$this
->_updateNode('2', array(
'nodesinblock_visibility' => '<front>',
));
$this
->drupalGet('user');
$this
->assertNoRaw('Text 2', 'Title 2 node not found');
$this
->assertNoRaw('Nodes in block 1', 'Block nodes in block 1 not found');
$this
->drupalGet('node');
$this
->assertRaw('Text 2', 'Title 2 node found');
$this
->assertRaw('Nodes in block 1', 'Block nodes in block 1 found');
// Update node and change block to 2.
$this
->_updateNode('2', array(
'nodesinblock_delta' => '1',
'nodesinblock_visibility' => '<front>',
));
$this
->drupalget('node/2/nodesinblock');
$this
->assertRaw('Nodes in block 2', 'Nodes in block 2 queue found');
$this
->drupalGet('node');
$this
->assertNoRaw('Nodes in block 1', 'Block nodes in block 1 not found');
$this
->assertRaw('Nodes in block 2', 'Block nodes in block 2 found');
$this
->assertRaw('Text 2', 'Title 2 node found');
// Create second node.
$this
->_createNode('page', '3');
$this
->assertRaw('Nodes in block 1', 'Nodes in block 1 queue found');
$this
->drupalGet('user');
$this
->assertRaw('Nodes in block 1', 'Block nodes in block 1 found');
$this
->assertRaw('Text 3', 'Title 3 node found');
$this
->assertNoRaw('Text 2', 'Title 2 node not found');
$this
->assertNoRaw('Nodes in block 2', 'Block nodes in block 2 not found');
$this
->drupalGet('node');
$this
->assertRaw('Nodes in block 2', 'Block nodes in block 2 found');
$this
->assertRaw('Text 2', 'Title 2 node found');
$this
->assertRaw('Nodes in block 1', 'Block nodes in block 1 found');
$this
->assertRaw('Text 3', 'Title 3 node found');
// Do some tests on visibility settings of blocks.
$this
->_updateNode('2', array(
'nodesinblock_delta' => '0',
'nodesinblock_visibility' => '*',
));
$this
->_updateNode('3', array(
'nodesinblock_delta' => '0',
'nodesinblock_visibility' => '<front>',
));
$visib = $this
->_getVisibility('0');
$visib = explode("\n", $visib);
$this
->assertTrue(in_array('<front>', $visib, '<front> visibility found.'));
$this
->assertTrue(in_array('*', $visib, '* visibility found.'));
$this
->_updateNode('2', array(
'nodesinblock_delta' => '0',
'nodesinblock_visibility' => 'node/add',
));
$this
->_updateNode('3', array(
'nodesinblock_delta' => '0',
'nodesinblock_visibility' => 'user',
));
$visib = $this
->_getVisibility('0');
$visib = explode("\n", $visib);
$this
->assertFalse(in_array('<front>', $visib, '<front> visibility not found.'));
$this
->assertFalse(in_array('*', $visib, '<front> visibility not found.'));
$this
->assertTrue(in_array('node/add', $visib, 'node/add visibility found.'));
$this
->assertTrue(in_array('user', $visib, 'user visibility found.'));
// Delete node and see
// 1: that record is gone in nodesinblock table.
// 2: visibility of block is good too.
node_delete('3');
$result = db_query("SELECT nid FROM {nodesinblock} WHERE nid = 3")
->fetchField();
$this
->assertFalse($result, 'Row has been deleted from nodesinblock table');
$visib = $this
->_getVisibility('0');
$visib = explode("\n", $visib);
$this
->assertFalse(in_array('user', $visib, 'user visibility not found.'));
$this
->assertTrue(in_array('node/add', $visib, 'node/add visibility found.'));
}