Skip to content

Commit

Permalink
Merge pull request #166 from joemcgill/test-filter-attributes
Browse files Browse the repository at this point in the history
Add tests for tevkori_filter_attachment_image_attributes() (resolves #159)
  • Loading branch information
joemcgill committed Sep 3, 2015
2 parents b7f9e6d + 080f9b3 commit 5a6fb0c
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/test-suite.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,57 @@ function test_tevkori_get_srcset_string() {
$this->assertSame( $expected, $sizes );
}

/**
* @group 159
*/
function test_tevkori_filter_attachment_image_attributes() {
// Make image.
$id = $this->_test_img();

// Get attachment post data.
$attachment = get_post( $id );
$image = wp_get_attachment_image_src( $id, 'medium' );
list($src, $width, $height) = $image;

// Create dummy attributes array.
$attr = array(
'src' => $src,
'width' => $width,
'height' => $height,
);

// Apply filter.
$resp_attr = tevkori_filter_attachment_image_attributes( $attr, $attachment, 'medium' );

// Test output.
$this->assertTrue( isset( $resp_attr['srcset'] ) );
$this->assertTrue( isset( $resp_attr['sizes'] ) );
}

/**
* @group 159
*/
function test_tevkori_filter_attachment_image_attributes_thumbnails() {
// Make image.
$id = $this->_test_img();

// Get attachment post data.
$attachment = get_post( $id );
$image = wp_get_attachment_image_src( $id, 'thumbnail' );
list($src, $width, $height) = $image;

// Create dummy attributes array.
$attr = array(
'src' => $src,
'width' => $width,
'height' => $height,
);

// Apply filter.
$resp_attr = tevkori_filter_attachment_image_attributes( $attr, $attachment, 'thumbnail' );

// Test output.
$this->assertFalse( isset( $resp_attr['srcset'] ) );
$this->assertFalse( isset( $resp_attr['sizes'] ) );
}
}

0 comments on commit 5a6fb0c

Please sign in to comment.