mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
wp-tests-config.php can/should reside in the root of a develop checkout. `phpunit` should be run from the root. see #25088. git-svn-id: https://develop.svn.wordpress.org/trunk@25165 602fd350-edb4-49c9-b593-d223f7449a82
51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group image
|
|
*/
|
|
abstract class WP_Image_UnitTestCase extends WP_UnitTestCase {
|
|
|
|
/**
|
|
* Set the image editor engine according to the unit test's specification
|
|
*/
|
|
public function setUp() {
|
|
if ( ! call_user_func( array( $this->editor_engine, 'test' ) ) ) {
|
|
$this->markTestSkipped( sprintf('The image editor engine %s is not supported on this system', $this->editor_engine) );
|
|
}
|
|
|
|
add_filter( 'wp_image_editors', array( $this, 'setEngine' ), 10, 2 );
|
|
}
|
|
|
|
/**
|
|
* Undo the image editor override
|
|
*/
|
|
public function tearDown() {
|
|
remove_filter( 'wp_image_editors', array( $this, 'setEngine' ), 10, 2 );
|
|
}
|
|
|
|
/**
|
|
* Override the image editor engine
|
|
* @return string
|
|
*/
|
|
public function setEngine( $editors ) {
|
|
return array( $this->editor_engine );
|
|
}
|
|
|
|
/**
|
|
* Helper assertion for testing alpha on images
|
|
*
|
|
* @param string $image_path
|
|
* @param array $point array(x,y)
|
|
* @param int $alpha
|
|
*/
|
|
protected function assertImageAlphaAtPoint( $image_path, $point, $alpha ) {
|
|
|
|
$im = imagecreatefrompng( $image_path );
|
|
$rgb = imagecolorat($im, $point[0], $point[1]);
|
|
|
|
$colors = imagecolorsforindex($im, $rgb);
|
|
|
|
$this->assertEquals( $alpha, $colors['alpha'] );
|
|
}
|
|
}
|