Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
/tests/testdata/modules/js-and-css/audit-enqueued-assets @manuelRod

# Module: Dominant Color Images
/modules/images/dominant-color @pbearne @spacedmonkey
/tests/modules/images/dominant-color @pbearne @spacedmonkey
/tests/testdata/modules/images/dominant-color @pbearne @spacedmonkey
/modules/images/dominant-color-images @pbearne @spacedmonkey
/tests/modules/images/dominant-color-images @pbearne @spacedmonkey
/tests/testdata/modules/images/dominant-color-images @pbearne @spacedmonkey

# Module: Fetchpriority
/modules/images/fetchpriority @pbearne @adamsilverstein
Expand Down
2 changes: 1 addition & 1 deletion default-enabled-modules.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */
return array(
'images/dominant-color',
'images/dominant-color-images',
'images/webp-support',
'images/webp-uploads',
);
Expand Down
1 change: 1 addition & 0 deletions load.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ function perflab_get_module_settings() {
'site-health/audit-autoloaded-options' => 'database/audit-autoloaded-options',
'site-health/audit-enqueued-assets' => 'js-and-css/audit-enqueued-assets',
'site-health/webp-support' => 'images/webp-support',
'images/dominant-color' => 'images/dominant-color-images',
);

foreach ( $legacy_module_slugs as $legacy_slug => $current_slug ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* with dominant color detection
*
* @package performance-lab
* @group dominant-color
* @group dominant-color-images
*
* @since 1.2.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* with dominant color detection
*
* @package performance-lab
* @group dominant-color
* @group dominant-color-images
*
* @since 1.2.0
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Module Name: Dominant Color Images
* Description: Adds support to store dominant color for an image and create a placeholder background with that color.
* Description: Adds support to store the dominant color of newly uploaded images and create a placeholder background of that color.
* Experimental: No
*
* @package performance-lab
Expand Down
11 changes: 6 additions & 5 deletions tests/load-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function test_perflab_get_modules_setting_default() {
public function test_perflab_get_module_settings() {
// Assert that by default the settings are using the same value as the registered default.
$settings = perflab_get_module_settings();
$this->assertSame( perflab_get_modules_setting_default(), $settings );
$this->assertEqualSetsWithIndex( perflab_get_modules_setting_default(), $settings );

// More specifically though, assert that the default is also passed through to the
// get_option() call, to support scenarios where the function is called before 'init'.
Expand All @@ -88,13 +88,13 @@ function( $default, $option, $passed_default ) use ( &$has_passed_default ) {
);
$settings = perflab_get_module_settings();
$this->assertTrue( $has_passed_default );
$this->assertSame( perflab_get_modules_setting_default(), $settings );
$this->assertEqualSetsWithIndex( perflab_get_modules_setting_default(), $settings );

// Assert that option updates are reflected in the settings correctly.
$new_value = array( 'my-module' => array( 'enabled' => true ) );
update_option( PERFLAB_MODULES_SETTING, $new_value );
$settings = perflab_get_module_settings();
$this->assertSame( $new_value, $settings );
$this->assertEqualSetsWithIndex( $new_value, $settings );
}

/**
Expand Down Expand Up @@ -124,6 +124,7 @@ public function data_legacy_modules() {
array( 'site-health/audit-autoloaded-options', 'database/audit-autoloaded-options' ),
array( 'site-health/audit-enqueued-assets', 'js-and-css/audit-enqueued-assets' ),
array( 'site-health/webp-support', 'images/webp-support' ),
array( 'images/dominant-color', 'images/dominant-color-images' ),
);
}

Expand All @@ -138,7 +139,7 @@ function( $module_settings ) {
}
)
);
$this->assertSame( $expected_active_modules, $active_modules );
$this->assertEqualSetsWithIndex( $expected_active_modules, $active_modules );

// Assert that option updates affect the active modules correctly.
$new_value = array(
Expand All @@ -147,7 +148,7 @@ function( $module_settings ) {
);
update_option( PERFLAB_MODULES_SETTING, $new_value );
$active_modules = perflab_get_active_modules();
$this->assertSame( array( 'active-module' ), $active_modules );
$this->assertEqualSetsWithIndex( array( 'active-module' ), $active_modules );
}

public function test_perflab_get_generator_content() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* Tests for dominant-color module.
* Tests for Dominant Color Images module.
*
* @package performance-lab
* @group dominant-color
* @group dominant-color-images
*/

use PerformanceLab\Tests\TestCase\DominantColorTestCase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
/**
* Tests for dominant-color module.
* Tests for Dominant Color Images module.
*
* @since 1.2.0
*
* @package performance-lab
* @group dominant-color
* @group dominant-color-images
*/

use PerformanceLab\Tests\TestCase\DominantColorTestCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

use PerformanceLab\Tests\TestCase\DominantColorTestCase;
/**
* Tests for dominant-color module.
* Tests for Dominant Color Images module.
*
* @package performance-lab
* @group dominant-color
* @group dominant-color-images
*/
class Dominant_Color_Test extends DominantColorTestCase {

Expand Down Expand Up @@ -120,7 +120,7 @@ public function test_tag_add_adjust_to_image_attributes( $image_path, $expected_
* @param bool $expected Whether the dominant color should be added.
*/
public function test_dominant_color_img_tag_add_dominant_color_requires_proper_quotes( $image, $expected ) {
$attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/red.jpg' );
$attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/red.jpg' );
wp_maybe_generate_attachment_metadata( get_post( $attachment_id ) );

$image_url = wp_get_attachment_image_url( $attachment_id );
Expand Down Expand Up @@ -168,7 +168,7 @@ public function data_dominant_color_img_tag_add_dominant_color_requires_proper_q
* @param string $expected The expected style attribute and value.
*/
public function test_dominant_color_img_tag_add_dominant_color_should_add_dominant_color_inline_style( $filtered_image, $expected ) {
$attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/red.jpg' );
$attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/red.jpg' );
wp_maybe_generate_attachment_metadata( get_post( $attachment_id ) );

list( $src, $width, $height ) = wp_get_attachment_image_src( $attachment_id );
Expand Down
42 changes: 21 additions & 21 deletions tests/utils/TestCase/DominantColorTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,85 +13,85 @@ abstract class DominantColorTestCase extends WP_UnitTestCase {
public function provider_get_dominant_color() {
return array(
'animated_gif' => array(
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/animated.gif',
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/animated.gif',
'expected_color' => array( '874e4e', 'df7f7f' ),
'expected_transparency' => true,
),
'red_jpg' => array(
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/red.jpg',
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/red.jpg',
'expected_color' => array( 'ff0000', 'fe0000' ),
'expected_transparency' => false,
),
'green_jpg' => array(
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/green.jpg',
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/green.jpg',
'expected_color' => array( '00ff00', '00ff01', '02ff01' ),
'expected_transparency' => false,
),
'white_jpg' => array(
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/white.jpg',
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/white.jpg',
'expected_color' => array( 'ffffff' ),
'expected_transparency' => false,
),

'red_gif' => array(
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/red.gif',
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/red.gif',
'expected_color' => array( 'ff0000' ),
'expected_transparency' => false,
),
'green_gif' => array(
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/green.gif',
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/green.gif',
'expected_color' => array( '00ff00' ),
'expected_transparency' => false,
),
'white_gif' => array(
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/white.gif',
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/white.gif',
'expected_color' => array( 'ffffff' ),
'expected_transparency' => false,
),
'trans_gif' => array(
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/trans.gif',
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/trans.gif',
'expected_color' => array( '5a5a5a', '020202' ),
'expected_transparency' => true,
),

'red_png' => array(
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/red.png',
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/red.png',
'expected_color' => array( 'ff0000' ),
'expected_transparency' => false,
),
'green_png' => array(
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/green.png',
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/green.png',
'expected_color' => array( '00ff00' ),
'expected_transparency' => false,
),
'white_png' => array(
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/white.png',
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/white.png',
'expected_color' => array( 'ffffff' ),
'expected_transparency' => false,
),
'trans_png' => array(
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/trans.png',
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/trans.png',
'expected_color' => array( '000000' ),
'expected_transparency' => true,
),

'red_webp' => array(
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/red.webp',
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/red.webp',
'expected_color' => array( 'ff0000' ),
'expected_transparency' => false,
),
'green_webp' => array(
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/green.webp',
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/green.webp',
'expected_color' => array( '00ff00' ),
'expected_transparency' => false,
),
'white_webp' => array(
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/white.webp',
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/white.webp',
'expected_color' => array( 'ffffff' ),
'expected_transparency' => false,
),
'trans_webp' => array(
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/trans.webp',
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/trans.webp',
'expected_color' => array( '000000' ),
'expected_transparency' => true,
),
Expand All @@ -111,12 +111,12 @@ public function provider_get_dominant_color() {
public function provider_get_dominant_color_invalid_images() {
return array(
'tiff' => array(
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/test-image.tiff',
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/test-image.tiff',
'expected_color' => array( 'dfdfdf' ),
'expected_transparency' => true,
),
'bmp' => array(
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/test-image.bmp',
'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/test-image.bmp',
'expected_color' => array( 'dfdfdf' ),
'expected_transparency' => true,
),
Expand All @@ -131,13 +131,13 @@ public function provider_get_dominant_color_invalid_images() {
public function provider_get_dominant_color_none_images() {
return array(
'svg' => array(
'files_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/video-play.svg',
'files_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/video-play.svg',
),
'pdf' => array(
'files_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/wordpress-gsoc-flyer.pdf',
'files_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/wordpress-gsoc-flyer.pdf',
),
'mp4' => array(
'files_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color/small-video.mp4',
'files_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/small-video.mp4',
),
);
}
Expand Down