Contao\CoreBundle\Test\Contao\GdImageTest::testCountColors PHP Method

testCountColors() public method

Tests the countColors() method.
public testCountColors ( )
    public function testCountColors()
    {
        $image = imagecreatetruecolor(100, 100);
        imagealphablending($image, false);
        imagefill($image, 0, 0, imagecolorallocatealpha($image, 255, 0, 0, 0));
        imagefilledrectangle($image, 50, 0, 100, 50, imagecolorallocatealpha($image, 0, 255, 0, 0));
        imagefilledrectangle($image, 0, 50, 50, 100, imagecolorallocatealpha($image, 0, 0, 255, 0));
        imagefilledrectangle($image, 50, 50, 100, 100, imagecolorallocatealpha($image, 0, 0, 0, 127));
        $image = new GdImage($image);
        $this->assertEquals(4, $image->countColors());
        $this->assertEquals(4, $image->countColors(256));
        $this->assertEquals(2, $image->countColors(1));
    }