]> granicus.if.org Git - php/commitdiff
Adding tests for imagecolorallocatealpha
authorRafael Machado Dohms <rdohms@php.net>
Mon, 24 Aug 2009 02:50:19 +0000 (02:50 +0000)
committerRafael Machado Dohms <rdohms@php.net>
Mon, 24 Aug 2009 02:50:19 +0000 (02:50 +0000)
ext/gd/tests/imagecolorallocatealpha_basic.phpt [new file with mode: 0644]
ext/gd/tests/imagecolorallocatealpha_error1.phpt [new file with mode: 0644]
ext/gd/tests/imagecolorallocatealpha_error2.phpt [new file with mode: 0644]
ext/gd/tests/imagecolorallocatealpha_error3.phpt [new file with mode: 0644]
ext/gd/tests/imagecolorallocatealpha_error4.phpt [new file with mode: 0644]
ext/gd/tests/imagecolorallocatealpha_error5.phpt [new file with mode: 0644]

diff --git a/ext/gd/tests/imagecolorallocatealpha_basic.phpt b/ext/gd/tests/imagecolorallocatealpha_basic.phpt
new file mode 100644 (file)
index 0000000..720c500
--- /dev/null
@@ -0,0 +1,30 @@
+--TEST--
+Testing imagecolorallocatealpha()
+--CREDITS--
+Rafael Dohms <rdohms [at] gmail [dot] com>
+--SKIPIF--
+<?php 
+       if (!extension_loaded("gd")) die("skip GD not present");
+?>
+--FILE--
+<?php
+$img = imagecreatetruecolor(150, 150);
+
+$cor = imagecolorallocate($img, 50, 100, 255);
+$corA = imagecolorallocatealpha($img, 50, 100, 255, 50);
+//$whiteA = imagecolorallocatealpha($img, 255, 255, 255, 127);
+
+$half =  imagefilledarc ( $img, 75, 75, 70, 70, 0, 180, $cor, IMG_ARC_PIE );
+$half2 =  imagefilledarc ( $img, 75, 75, 70, 70, 180, 360, $corA, IMG_ARC_PIE );
+
+ob_start();
+imagepng($img, null, 9);
+$imgsrc = ob_get_contents();
+ob_end_clean();
+
+var_dump(md5(base64_encode($imgsrc)));
+var_dump($corA);
+?>
+--EXPECT--
+string(32) "b856a0b1a15efe0f79551ebbb5651fe8"
+int(842163455)
\ No newline at end of file
diff --git a/ext/gd/tests/imagecolorallocatealpha_error1.phpt b/ext/gd/tests/imagecolorallocatealpha_error1.phpt
new file mode 100644 (file)
index 0000000..1178b9c
--- /dev/null
@@ -0,0 +1,25 @@
+--TEST--
+Testing imagecolorallocatealpha(): Wrong types for parameter 1
+--CREDITS--
+Rafael Dohms <rdohms [at] gmail [dot] com>
+--SKIPIF--
+<?php 
+       if (!extension_loaded("gd")) die("skip GD not present");
+?>
+--FILE--
+<?php
+$resource = tmpfile();
+
+imagecolorallocatealpha($resource, 255, 255, 255, 50);
+imagecolorallocatealpha('string', 255, 255, 255, 50);
+imagecolorallocatealpha(array(), 255, 255, 255, 50);
+imagecolorallocatealpha(null, 255, 255, 255, 50);
+?>
+--EXPECTF--
+Warning: imagecolorallocatealpha(): supplied resource is not a valid Image resource in %s on line %d
+
+Warning: imagecolorallocatealpha(): supplied argument is not a valid Image resource in %s on line %d
+
+Warning: imagecolorallocatealpha(): supplied argument is not a valid Image resource in %s on line %d
+
+Warning: imagecolorallocatealpha(): supplied argument is not a valid Image resource in %s on line %d
\ No newline at end of file
diff --git a/ext/gd/tests/imagecolorallocatealpha_error2.phpt b/ext/gd/tests/imagecolorallocatealpha_error2.phpt
new file mode 100644 (file)
index 0000000..ba9e5de
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Testing imagecolorallocatealpha(): Wrong types for parameter 2
+--CREDITS--
+Rafael Dohms <rdohms [at] gmail [dot] com>
+--SKIPIF--
+<?php 
+       if (!extension_loaded("gd")) die("skip GD not present");
+?>
+--FILE--
+<?php
+$img = imagecreatetruecolor(200, 200);
+
+imagecolorallocatealpha($img, 'string-non-numeric', 255, 255, 50);
+imagecolorallocatealpha($img, array(), 255, 255, 50);
+imagecolorallocatealpha($img, tmpfile(), 255, 255, 50);
+?>
+--EXPECTF--
+Warning: imagecolorallocatealpha() expects parameter 2 to be long, %s given in %s on line %d
+
+Warning: imagecolorallocatealpha() expects parameter 2 to be long, array given in %s on line %d
+
+Warning: imagecolorallocatealpha() expects parameter 2 to be long, resource given in %s on line %d
\ No newline at end of file
diff --git a/ext/gd/tests/imagecolorallocatealpha_error3.phpt b/ext/gd/tests/imagecolorallocatealpha_error3.phpt
new file mode 100644 (file)
index 0000000..ee8f646
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Testing imagecolorallocatealpha(): Wrong types for parameter 3
+--CREDITS--
+Rafael Dohms <rdohms [at] gmail [dot] com>
+--SKIPIF--
+<?php 
+       if (!extension_loaded("gd")) die("skip GD not present");
+?>
+--FILE--
+<?php
+$img = imagecreatetruecolor(200, 200);
+
+imagecolorallocatealpha($img, 255, 'string-non-numeric', 255, 50);
+imagecolorallocatealpha($img, 255, array(), 255, 50);
+imagecolorallocatealpha($img, 255, tmpfile(), 255, 50);
+?>
+--EXPECTF--
+Warning: imagecolorallocatealpha() expects parameter 3 to be long, %s given in %s on line %d
+
+Warning: imagecolorallocatealpha() expects parameter 3 to be long, array given in %s on line %d
+
+Warning: imagecolorallocatealpha() expects parameter 3 to be long, resource given in %s on line %d
\ No newline at end of file
diff --git a/ext/gd/tests/imagecolorallocatealpha_error4.phpt b/ext/gd/tests/imagecolorallocatealpha_error4.phpt
new file mode 100644 (file)
index 0000000..2b5b471
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Testing imagecolorallocatealpha(): Wrong types for parameter 4
+--CREDITS--
+Rafael Dohms <rdohms [at] gmail [dot] com>
+--SKIPIF--
+<?php 
+       if (!extension_loaded("gd")) die("skip GD not present");
+?>
+--FILE--
+<?php
+$img = imagecreatetruecolor(200, 200);
+
+imagecolorallocatealpha($img, 255, 255, 'string-non-numeric', 50);
+imagecolorallocatealpha($img, 255, 255, array(), 50);
+imagecolorallocatealpha($img, 255, 255, tmpfile(), 50);
+?>
+--EXPECTF--
+Warning: imagecolorallocatealpha() expects parameter 4 to be long, %s given in %s on line %d
+
+Warning: imagecolorallocatealpha() expects parameter 4 to be long, array given in %s on line %d
+
+Warning: imagecolorallocatealpha() expects parameter 4 to be long, resource given in %s on line %d
\ No newline at end of file
diff --git a/ext/gd/tests/imagecolorallocatealpha_error5.phpt b/ext/gd/tests/imagecolorallocatealpha_error5.phpt
new file mode 100644 (file)
index 0000000..2d77833
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Testing imagecolorallocatealpha(): Wrong types for parameter 5
+--CREDITS--
+Rafael Dohms <rdohms [at] gmail [dot] com>
+--SKIPIF--
+<?php 
+       if (!extension_loaded("gd")) die("skip GD not present");
+?>
+--FILE--
+<?php
+$img = imagecreatetruecolor(200, 200);
+
+imagecolorallocatealpha($img, 255, 255, 255, 'string-non-numeric');
+imagecolorallocatealpha($img, 255, 255, 255, array());
+imagecolorallocatealpha($img, 255, 255, 255, tmpfile());
+?>
+--EXPECTF--
+Warning: imagecolorallocatealpha() expects parameter 5 to be long, %s given in %s on line %d
+
+Warning: imagecolorallocatealpha() expects parameter 5 to be long, array given in %s on line %d
+
+Warning: imagecolorallocatealpha() expects parameter 5 to be long, resource given in %s on line %d
\ No newline at end of file