You are here

public function GdImageAnalysisTest::testHistogram in Image Effects 8.3

Same name and namespace in other branches
  1. 8 tests/src/Unit/GdImageAnalysisTest.php \Drupal\Tests\image_effects\Unit\GdImageAnalysisTest::testHistogram()
  2. 8.2 tests/src/Unit/GdImageAnalysisTest.php \Drupal\Tests\image_effects\Unit\GdImageAnalysisTest::testHistogram()

Verify the histogram calculation with a known image.

File

tests/src/Unit/GdImageAnalysisTest.php, line 61

Class

GdImageAnalysisTest
Tests the image analysis helper methods.

Namespace

Drupal\Tests\image_effects\Unit

Code

public function testHistogram() {
  $expected_histogram = [
    0 => 6,
    255 => 3,
    256 => 6,
    511 => 3,
    512 => 6,
    767 => 3,
  ];
  $this
    ->assertEquals($expected_histogram, array_filter(GdImageAnalysis::histogram($this->testImage)));
}