mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 12:50:28 +00:00
Move PHPUnit tests into a tests/phpunit directory.
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
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?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'] );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user