function OGMTBasicTest::testExtractImagesFromNode in Open Graph meta tags 7.2
Same name and namespace in other branches
- 6 tests/Basic.test \OGMTBasicTest::testExtractImagesFromNode()
- 7 tests/Basic.test \OGMTBasicTest::testExtractImagesFromNode()
File
- tests/
Basic.test, line 19
Class
- OGMTBasicTest
- Tests for Open Graph meta tags.
Code
function testExtractImagesFromNode() {
/*
* Check that logic to extract image URLs from the node body works as expected.
*/
$node = new stdClass();
$this
->_set_node_body($node, 'bla bla bla <a href="this is">...<img src="body.jpg">...<img> <img src=""></p>');
$node->type = 'page';
$node->field_image = $this
->_create_img_field('image', 'field1.jpg');
$node->field_no_image = $this
->_create_img_field('pdf', 'field2.jpg');
$node->sub_field_image = array(
'child' => $this
->_create_img_field('image', 'subfield.jpg'),
);
$ret = $this->ogm
->harvestImagesFromNode($node);
$expected = array();
foreach (array(
'field1.jpg',
'subfield.jpg',
'body.jpg',
) as $imgpath) {
$url = image_style_url('thumbnail', $imgpath);
$expected[$imgpath] = array(
'title' => $imgpath,
'alt' => $imgpath,
'url' => $url,
);
}
$this
->assertEqual(serialize($expected), serialize($ret), t('Extract images from node fields and body content'));
}