public function JuiceboxFieldFormatterCase::testFieldFormatterAccess in Juicebox HTML5 Responsive Image Galleries 7.2
Test access to the Juicebox XML for the field formatter.
File
- tests/
JuiceboxFieldFormatterCase.test, line 115 - Test case for Juicebox field formatter.
Class
- JuiceboxFieldFormatterCase
- Class to define test case for Juicebox field formatter.
Code
public function testFieldFormatterAccess() {
$instance = $this->instance;
$node = $this->node;
// Begin testing as an anon user.
$this
->drupalLogout();
// The XML should be initially accessible (control test).
$this
->drupalGet('juicebox/xml/field/node/' . $node->nid . '/' . $instance['field_name'] . '/full');
$this
->assertRaw('<?xml version="1.0" encoding="UTF-8"?>', 'XML access allowed to published node (valid XML detected).');
// Now unpublish the node as a way of making it inaccessible to
// non-privileged users. There are unlimited ways that access can be
// restricted, such as other perm settings, contrb module controls for
// entities (node_access, tac, etc.), contrb module controls for fields
// (field_permissions), etc. We can't test them all here, but we can run
// this basic check to ensure that XML access restrictions kick-in.
$node->status = 0;
node_save($node);
// Re-check access.
$this
->drupalGet('juicebox/xml/field/node/' . $node->nid . '/' . $instance['field_name'] . '/full');
$this
->assertResponse(403, 'XML access blocked for unpublished node.');
}