Skip to content
Browse files

more tests and some includes added - synced php_cairo and php_cairo_a…

…pi structures
  • Loading branch information...
1 parent 9b1bd20 commit bf7cb094835d3216d4aaa650a93203c142b9c2d6 @auroraeosrose auroraeosrose committed Jun 9, 2009
View
1 cairo_image_surface.c
@@ -28,6 +28,7 @@
#include "php.h"
#include "php_cairo.h"
+#include "zend_exceptions.h"
zend_class_entry *cairo_ce_cairoimagesurface;
zend_class_entry *cairo_ce_cairoformat;
View
1 cairo_pdf_surface.c
@@ -31,6 +31,7 @@
#include "php.h"
#include "php_cairo.h"
+#include "zend_exceptions.h"
zend_class_entry *cairo_ce_cairopdfsurface;
View
1 cairo_ps_surface.c
@@ -31,6 +31,7 @@
#include "php.h"
#include "php_cairo.h"
+#include "zend_exceptions.h"
zend_class_entry *cairo_ce_cairopssurface;
zend_class_entry *cairo_ce_cairopslevel;
View
1 cairo_surface.c
@@ -28,6 +28,7 @@
#include "php.h"
#include "php_cairo.h"
+#include "zend_exceptions.h"
zend_class_entry *cairo_ce_cairosurface;
zend_class_entry *cairo_ce_cairocontent;
View
3 examples/operator-source.php
@@ -191,5 +191,4 @@ function draw_rects ($x, $y)
}
}
-$sur->writeToPng(dirname(__FILE__) . "/operator-source-php.png");
-?>
+$sur->writeToPng(dirname(__FILE__) . '/operator-source.png');
View
11 php_cairo.h
@@ -35,6 +35,15 @@ extern zend_module_entry cairo_module_entry;
# define PHP_CAIRO_API
#endif
+/* Silly compilers */
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
/* 5.2 is stupid and needs some additional stuff */
#ifndef zend_parse_parameters_none
#define zend_parse_parameters_none() \
@@ -118,6 +127,8 @@ PHP_MINIT_FUNCTION(cairo_surface);
PHP_MINIT_FUNCTION(cairo_font);
PHP_MINIT_FUNCTION(cairo_image_surface);
PHP_MINIT_FUNCTION(cairo_svg_surface);
+PHP_MINIT_FUNCTION(cairo_pdf_surface);
+PHP_MINIT_FUNCTION(cairo_ps_surface);
PHP_FUNCTION(cairo_version);
PHP_FUNCTION(cairo_version_string);
View
34 php_cairo_api.h
@@ -24,40 +24,56 @@
#include <php.h>
#include <cairo.h>
+typedef struct _stream_closure {
+ php_stream *stream;
+ zend_bool owned_stream;
+#ifdef ZTS
+ TSRMLS_D;
+#endif
+} stream_closure;
+
typedef struct _cairo_context_object {
zend_object std;
+ zval *surface;
+ zval *matrix;
+ zval *pattern;
cairo_t *context;
} cairo_context_object;
typedef struct _cairo_pattern_object {
zend_object std;
+ zval *matrix;
+ zval *surface;
cairo_pattern_t *pattern;
} cairo_pattern_object;
typedef struct _cairo_surface_object {
zend_object std;
cairo_surface_t *surface;
+ char * buffer;
+ stream_closure *closure;
+ stream_closure *writer;
} cairo_surface_object;
+typedef struct _cairo_matrix_object {
+ zend_object std;
+ cairo_matrix_t *matrix;
+} cairo_matrix_object;
+
typedef struct _cairo_path_object {
zend_object std;
cairo_path_t *path;
} cairo_path_object;
-typedef struct _cairo_fontoptions_object {
- zend_object std;
- cairo_font_options_t *fontoptions;
-} cairo_fontoptions_object;
-
typedef struct _cairo_fontface_object {
zend_object std;
- cairo_font_face_t *fontface;
+ cairo_font_face_t *font_face;
} cairo_fontface_object;
-typedef struct _cairo_matrix_object {
+typedef struct _cairo_fontoptions_object {
zend_object std;
- cairo_matrix_t *matrix;
-} cairo_matrix_object;
+ cairo_font_options_t *font_options;
+} cairo_fontoptions_object;
typedef struct _cairo_scaledfont_object {
zend_object std;
View
27 tests/CairoPattern/CairoGradientPattern/__construct.phpt
@@ -0,0 +1,27 @@
+--TEST--
+new CairoGradientPattern [ __construct method ]
+--SKIPIF--
+<?php
+if(!extension_loaded('cairo')) die('skip - Cairo extension not available');
+?>
+--FILE--
+<?php
+class test extends CairoGradientPattern {}
+
+class test2 extends CairoGradientPattern {
+ public function __construct() {}
+}
+try {
+ $pattern = new test();
+ echo 'Attempting to use constructor should throw an exception';
+} catch (CairoException $e) {
+ echo $e->getMessage();
+}
+
+$pattern = new test2();
+$pattern->getType();
+echo 'First call to any method should throw a fatal error';
+?>
+--EXPECTF--
+CairoPattern cannot be constructed
+Fatal error: Internal pattern object missing in test2 wrapper, you must call parent::__construct in extended classes in %s on line %d
View
75 tests/CairoPattern/CairoGradientPattern/addColorStopRgb.phpt
@@ -6,15 +6,69 @@ if(!extension_loaded('cairo')) die('skip - Cairo extension not available');
?>
--FILE--
<?php
-$red = 0.8;
-$green = 0.6;
-$blue = 0.5;
-
$pattern = new CairoLinearGradient(1, 2, 3, 4);
var_dump($pattern);
-$pattern->addColorStopRgb(0.2, $red, $green, $blue);
+$pattern->addColorStopRgb(0.2, 0.8, 0.6, 0.5);
var_dump($pattern->getColorStopRgba(0));
+
+/* Total number of args needed = 4 */
+try {
+ $pattern->addColorStopRgb();
+ trigger_error('addColorStopRgb with no args');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+try {
+ $pattern->addColorStopRgb(1);
+ trigger_error('addColorStopRgb with 1 arg');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+try {
+ $pattern->addColorStopRgb(1, 1);
+ trigger_error('addColorStopRgb with 2 args');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+try {
+ $pattern->addColorStopRgb(1, 1, 1);
+ trigger_error('addColorStopRgb with 3 args');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+try {
+ $pattern->addColorStopRgb(1, 1, 1, 1, 1);
+ trigger_error('addColorStopRgb with too many args');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+
+/* All 4 args must be double/float or castable to double/float */
+try {
+ $pattern->addColorStopRgb(array(), 1, 1, 1);
+ trigger_error('Arg 1 must be double');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+try {
+ $pattern->addColorStopRgb(1, array(), 1, 1);
+ trigger_error('Arg 2 must be double');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+try {
+ $pattern->addColorStopRgb(1, 1, array(), 1);
+ trigger_error('Arg 3 must be double');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+try {
+ $pattern->addColorStopRgb(1, 1, 1, array());
+ trigger_error('Arg 4 must be double');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
?>
--EXPECTF--
object(CairoLinearGradient)#%d (0) {
@@ -28,4 +82,13 @@ array(4) {
float(0.5%A)
["alpha"]=>
float(1)
-}
+}
+CairoGradientPattern::addColorStopRgb() expects exactly 4 parameters, 0 given
+CairoGradientPattern::addColorStopRgb() expects exactly 4 parameters, 1 given
+CairoGradientPattern::addColorStopRgb() expects exactly 4 parameters, 2 given
+CairoGradientPattern::addColorStopRgb() expects exactly 4 parameters, 3 given
+CairoGradientPattern::addColorStopRgb() expects exactly 4 parameters, 5 given
+CairoGradientPattern::addColorStopRgb() expects parameter 1 to be double, array given
+CairoGradientPattern::addColorStopRgb() expects parameter 2 to be double, array given
+CairoGradientPattern::addColorStopRgb() expects parameter 3 to be double, array given
+CairoGradientPattern::addColorStopRgb() expects parameter 4 to be double, array given
View
90 tests/CairoPattern/CairoGradientPattern/addColorStopRgba.phpt
@@ -6,16 +6,81 @@ if(!extension_loaded('cairo')) die('skip - Cairo extension not available');
?>
--FILE--
<?php
-$red = 0.8;
-$green = 0.6;
-$blue = 0.5;
-$alpha = 0.2;
-
$pattern = new CairoLinearGradient(1, 2, 3, 4);
var_dump($pattern);
-$pattern->addColorStopRgba(0.2, $red, $green, $blue, $alpha);
+$pattern->addColorStopRgba(0.2, 0.8, 0.6, 0.5, 0.2);
var_dump($pattern->getColorStopRgba(0));
+
+/* Total number of args needed = 5 */
+try {
+ $pattern->addColorStopRgba();
+ trigger_error('addColorStopRgba with no args');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+try {
+ $pattern->addColorStopRgba(1);
+ trigger_error('addColorStopRgba with 1 arg');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+try {
+ $pattern->addColorStopRgba(1, 1);
+ trigger_error('addColorStopRgba with 2 args');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+try {
+ $pattern->addColorStopRgba(1, 1, 1);
+ trigger_error('addColorStopRgba with 3 args');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+try {
+ $pattern->addColorStopRgba(1, 1, 1, 1);
+ trigger_error('addColorStopRgba with 4 args');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+try {
+ $pattern->addColorStopRgba(1, 1, 1, 1, 1, 1);
+ trigger_error('addColorStopRgba with too many args');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+
+/* All 5 args must be double/float or castable to double/float */
+try {
+ $pattern->addColorStopRgba(array(), 1, 1, 1, 1);
+ trigger_error('Arg 1 must be double');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+try {
+ $pattern->addColorStopRgba(1, array(), 1, 1, 1);
+ trigger_error('Arg 2 must be double');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+try {
+ $pattern->addColorStopRgba(1, 1, array(), 1, 1);
+ trigger_error('Arg 3 must be double');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+try {
+ $pattern->addColorStopRgba(1, 1, 1, array(), 1);
+ trigger_error('Arg 4 must be double');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+try {
+ $pattern->addColorStopRgba(1, 1, 1, 1, array());
+ trigger_error('Arg 5 must be double');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
?>
--EXPECTF--
object(CairoLinearGradient)#%d (0) {
@@ -29,4 +94,15 @@ array(4) {
float(0.5%A)
["alpha"]=>
float(0.2%A)
-}
+}
+CairoGradientPattern::addColorStopRgba() expects exactly 5 parameters, 0 given
+CairoGradientPattern::addColorStopRgba() expects exactly 5 parameters, 1 given
+CairoGradientPattern::addColorStopRgba() expects exactly 5 parameters, 2 given
+CairoGradientPattern::addColorStopRgba() expects exactly 5 parameters, 3 given
+CairoGradientPattern::addColorStopRgba() expects exactly 5 parameters, 4 given
+CairoGradientPattern::addColorStopRgba() expects exactly 5 parameters, 6 given
+CairoGradientPattern::addColorStopRgba() expects parameter 1 to be double, array given
+CairoGradientPattern::addColorStopRgba() expects parameter 2 to be double, array given
+CairoGradientPattern::addColorStopRgba() expects parameter 3 to be double, array given
+CairoGradientPattern::addColorStopRgba() expects parameter 4 to be double, array given
+CairoGradientPattern::addColorStopRgba() expects parameter 5 to be double, array given
View
15 tests/CairoPattern/CairoGradientPattern/cairo_pattern_get_color_stop_count.phpt
@@ -19,6 +19,21 @@ cairo_pattern_add_color_stop_rgba($pattern, 0.2, $red, $green, $blue, $alpha);
cairo_pattern_add_color_stop_rgba($pattern, 0.4, $red, $green, $blue, $alpha);
cairo_pattern_add_color_stop_rgba($pattern, 0.5, $red, $green, $blue, $alpha);
var_dump(cairo_pattern_get_color_stop_count($pattern));
+
+// bad type hint is an E_RECOVERABLE_ERROR, so let's hook a handler
+function bad_class($errno, $errstr) {
+ echo 'CAUGHT ERROR: ' . $errstr, PHP_EOL;
+}
+set_error_handler('bad_class', E_RECOVERABLE_ERROR);
+
+// requires 2 args
+cairo_pattern_get_color_stop_count();
+cairo_pattern_get_color_stop_count($pattern);
+cairo_pattern_get_color_stop_count($pattern, 1, 1);
+
+// arg types are CairoPattern, int
+cairo_pattern_get_color_stop_count(1, 1);
+cairo_pattern_get_color_stop_count($pattern, array());
?>
--EXPECTF--
object(CairoLinearGradient)#%d (0) {
View
11 tests/CairoPattern/CairoGradientPattern/getColorStopCount.phpt
@@ -19,9 +19,18 @@ $pattern->addColorStopRgba(0.2, $red, $green, $blue, $alpha);
$pattern->addColorStopRgba(0.4, $red, $green, $blue, $alpha);
$pattern->addColorStopRgba(0.6, $red, $green, $blue, $alpha);
var_dump($pattern->getColorStopCount());
+
+/* Total number of args needed = 0 */
+try {
+ $pattern->getColorStopCount(1);
+ trigger_error('getColorStopCount with too many args');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
?>
--EXPECTF--
object(CairoLinearGradient)#%d (0) {
}
int(0)
-int(3)
+int(3)
+CairoGradientPattern::getColorStopCount() expects exactly 0 parameters, 1 given
View
34 tests/CairoPattern/CairoGradientPattern/getColorStopRgba.phpt
@@ -6,16 +6,33 @@ if(!extension_loaded('cairo')) die('skip - Cairo extension not available');
?>
--FILE--
<?php
-$red = 0.8;
-$green = 0.6;
-$blue = 0.5;
-$alpha = 0.2;
-
$pattern = new CairoLinearGradient(1, 2, 3, 4);
var_dump($pattern);
-$pattern->addColorStopRgba(0.2, $red, $green, $blue, $alpha);
+$pattern->addColorStopRgba(0.2, 0.8, 0.6, 0.5, 0.2);
var_dump($pattern->getColorStopRgba(0));
+
+/* Total number of args needed = 1 */
+try {
+ $pattern->getColorStopRgba();
+ trigger_error('getColorStopRgba with no args');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+try {
+ $pattern->getColorStopRgba(1, 1);
+ trigger_error('getColorStopRgba with too many args');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+
+/* arg must be int or castable to int */
+try {
+ $pattern->getColorStopRgba(array());
+ trigger_error('Arg 1 must be int');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
?>
--EXPECTF--
object(CairoLinearGradient)#%d (0) {
@@ -29,4 +46,7 @@ array(4) {
float(0.5%A)
["alpha"]=>
float(0.2%A)
-}
+}
+CairoGradientPattern::getColorStopRgba() expects exactly 1 parameter, 0 given
+CairoGradientPattern::getColorStopRgba() expects exactly 1 parameter, 2 given
+CairoGradientPattern::getColorStopRgba() expects parameter 1 to be long, array given
View
29 tests/CairoPattern/CairoGradientPattern/getExtend.phpt
@@ -0,0 +1,29 @@
+--TEST--
+CairoGradientPattern->getExtend() method
+--SKIPIF--
+<?php
+if(!extension_loaded('cairo')) die('skip - Cairo extension not available');
+?>
+--FILE--
+<?php
+$pattern = new CairoLinearGradient(1, 2, 3, 4);
+var_dump($pattern);
+
+$extend = $pattern->getExtend();
+var_dump($extend);
+var_dump($extend == CairoExtend::PAD);
+
+/* Total number of args needed = 0 */
+try {
+ $pattern->getExtend(1);
+ trigger_error('getExtend with too many args');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+?>
+--EXPECTF--
+object(CairoLinearGradient)#%d (0) {
+}
+int(3)
+bool(true)
+CairoGradientPattern::getExtend() expects exactly 0 parameters, 1 given
View
47 tests/CairoPattern/CairoGradientPattern/setExtend.phpt
@@ -0,0 +1,47 @@
+--TEST--
+CairoGradientPattern->setExtend() method
+--SKIPIF--
+<?php
+if(!extension_loaded('cairo')) die('skip - Cairo extension not available');
+?>
+--FILE--
+<?php
+$pattern = new CairoLinearGradient(1, 2, 3, 4);
+var_dump($pattern);
+
+$pattern->setExtend(CairoExtend::REFLECT);
+
+$extend = $pattern->getExtend();
+var_dump($extend);
+var_dump($extend == CairoExtend::REFLECT);
+
+/* Total number of args needed = 1 */
+try {
+ $pattern->setExtend();
+ trigger_error('setExtend with no args');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+try {
+ $pattern->setExtend(1, 1);
+ trigger_error('setExtend with too many args');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+
+/* arg must be int or castable to int */
+try {
+ $pattern->setExtend(array());
+ trigger_error('Arg 1 must be int');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+?>
+--EXPECTF--
+object(CairoLinearGradient)#%d (0) {
+}
+int(2)
+bool(true)
+CairoGradientPattern::setExtend() expects exactly 1 parameter, 0 given
+CairoGradientPattern::setExtend() expects exactly 1 parameter, 2 given
+CairoGradientPattern::setExtend() expects parameter 1 to be long, array given
View
54 tests/CairoPattern/cairo_pattern_get_matrix.phpt
@@ -0,0 +1,54 @@
+--TEST--
+cairo_pattern_get_matrix function
+--SKIPIF--
+<?php
+if(!extension_loaded('cairo')) die('skip - Cairo extension not available');
+?>
+--FILE--
+<?php
+$pattern = cairo_pattern_create_rgb(0.8, 0.6, 0.5);
+var_dump($pattern);
+
+var_dump($orig_matrix = cairo_pattern_get_matrix($pattern));
+
+$matrix = cairo_matrix_init(5, 5);
+var_dump($matrix);
+var_dump($orig_matrix === $matrix);
+
+cairo_pattern_set_matrix($pattern, $matrix);
+var_dump($matrix1 = cairo_pattern_get_matrix($pattern));
+var_dump($matrix1 === $matrix);
+var_dump($orig_matrix === $matrix);
+
+// bad type hint is an E_RECOVERABLE_ERROR, so let's hook a handler
+function bad_class($errno, $errstr) {
+ echo 'CAUGHT ERROR: ' . $errstr, PHP_EOL;
+}
+set_error_handler('bad_class', E_RECOVERABLE_ERROR);
+
+// requires exactly 1 arg
+cairo_pattern_get_matrix();
+cairo_pattern_get_matrix($pattern, 1);
+
+// arg types is CairoPattern
+cairo_pattern_get_matrix(1);
+?>
+--EXPECTF--
+object(CairoSolidPattern)#%d (0) {
+}
+object(CairoMatrix)#%d (0) {
+}
+object(CairoMatrix)#%d (0) {
+}
+bool(false)
+object(CairoMatrix)#%d (0) {
+}
+bool(true)
+bool(false)
+
+Warning: cairo_pattern_get_matrix() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: cairo_pattern_get_matrix() expects exactly 1 parameter, 2 given in %s on line %d
+CAUGHT ERROR: Argument 1 passed to cairo_pattern_get_matrix() must be an instance of CairoPattern, integer given
+
+Warning: cairo_pattern_get_matrix() expects parameter 1 to be CairoPattern, integer given in %s on line %d
View
41 tests/CairoPattern/cairo_pattern_get_type.phpt
@@ -0,0 +1,41 @@
+--TEST--
+cairo_pattern_get_type() function
+--SKIPIF--
+<?php
+if(!extension_loaded('cairo')) die('skip - Cairo extension not available');
+?>
+--FILE--
+<?php
+$surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 50, 50);
+var_dump($surface);
+
+$pattern = cairo_pattern_create_for_surface($surface);
+var_dump($pattern);
+
+var_dump(cairo_pattern_get_type($pattern));
+
+// bad type hint is an E_RECOVERABLE_ERROR, so let's hook a handler
+function bad_class($errno, $errstr) {
+ echo 'CAUGHT ERROR: ' . $errstr, PHP_EOL;
+}
+set_error_handler('bad_class', E_RECOVERABLE_ERROR);
+
+// requires exactly 1 arg
+cairo_pattern_get_type();
+cairo_pattern_get_type($pattern);
+
+// arg type is CairoSurface
+cairo_pattern_get_type(1);
+cairo_pattern_get_type($pattern);
+?>
+--EXPECTF--
+object(CairoImageSurface)#%d (0) {
+}
+object(CairoSurfacePattern)#%d (0) {
+}
+int(1)
+
+Warning: cairo_pattern_get_type() expects exactly 1 parameter, 0 given in %s on line %d
+CAUGHT ERROR: Argument 1 passed to cairo_pattern_get_type() must be an instance of CairoPattern, integer given
+
+Warning: cairo_pattern_get_type() expects parameter 1 to be CairoPattern, integer given in %s on line %d
View
34 tests/CairoPattern/cairo_pattern_set_matrix.phpt
@@ -13,13 +13,45 @@ $matrix = cairo_matrix_init();
var_dump($matrix);
cairo_pattern_set_matrix($pattern, $matrix);
+$matrix1 = cairo_pattern_get_matrix($pattern);
+var_dump($matrix === $matrix1);
+$matrix2 = cairo_matrix_init(5, 5);
+cairo_pattern_set_matrix($pattern, $matrix2);
+$matrix1 = cairo_pattern_get_matrix($pattern);
+var_dump($matrix2 === $matrix1);
+
+// bad type hint is an E_RECOVERABLE_ERROR, so let's hook a handler
+function bad_class($errno, $errstr) {
+ echo 'CAUGHT ERROR: ' . $errstr, PHP_EOL;
+}
+set_error_handler('bad_class', E_RECOVERABLE_ERROR);
+
+// requires exactly 2 args
cairo_pattern_set_matrix();
+cairo_pattern_set_matrix($pattern);
+cairo_pattern_set_matrix($pattern, $matrix, 1);
+
+// arg types are CairoSurface and CairoMatrix
+cairo_pattern_set_matrix(1, $matrix);
+cairo_pattern_set_matrix($pattern, 1);
?>
--EXPECTF--
object(CairoSolidPattern)#%d (0) {
}
object(CairoMatrix)#%d (0) {
}
+bool(true)
+bool(true)
+
+Warning: cairo_pattern_set_matrix() expects exactly 2 parameters, 0 given in %s on line %d
+
+Warning: cairo_pattern_set_matrix() expects exactly 2 parameters, 1 given in %s on line %d
+
+Warning: cairo_pattern_set_matrix() expects exactly 2 parameters, 3 given in %s on line %d
+CAUGHT ERROR: Argument 1 passed to cairo_pattern_set_matrix() must be an instance of CairoPattern, integer given
+
+Warning: cairo_pattern_set_matrix() expects parameter 1 to be CairoPattern, integer given in %s on line %d
+CAUGHT ERROR: Argument 2 passed to cairo_pattern_set_matrix() must be an instance of CairoMatrix, integer given
-Warning: cairo_pattern_set_matrix() expects exactly 2 parameters, 0 given in %s on line %d
+Warning: cairo_pattern_set_matrix() expects parameter 2 to be CairoMatrix, integer given in %s on line %d
View
2 tests/CairoPattern/cairo_pattern_status.phpt
@@ -1,5 +1,5 @@
--TEST--
-cairo_pattern_status function
+cairo_pattern_status() function
--SKIPIF--
<?php
if(!extension_loaded('cairo')) die('skip - Cairo extension not available');
View
34 tests/CairoPattern/getMatrix.phpt
@@ -9,31 +9,20 @@ if(!extension_loaded('cairo')) die('skip - Cairo extension not available');
$pattern = new CairoSolidPattern(0.8, 0.6, 0.5);
var_dump($pattern);
-var_dump($pattern->getMatrix());
+var_dump($orig_matrix = $pattern->getMatrix());
-$matrix = new CairoMatrix();
+$matrix = new CairoMatrix(5, 5);
var_dump($matrix);
+var_dump($orig_matrix === $matrix);
$pattern->setMatrix($matrix);
-var_dump($pattern->getMatrix());
+var_dump($matrix1 = $pattern->getMatrix());
+var_dump($matrix1 === $matrix);
+var_dump($orig_matrix === $matrix);
try {
- $pattern->setMatrix();
- trigger_error('Set matrix requires one arg');
-} catch (CairoException $e) {
- echo $e->getMessage(), PHP_EOL;
-}
-
-try {
- $pattern->setMatrix(1, 1);
- trigger_error('Set matrix requires only one arg');
-} catch (CairoException $e) {
- echo $e->getMessage(), PHP_EOL;
-}
-
-try {
- $pattern->setMatrix(1);
- trigger_error('Set matrix requires instanceof Cairomatrix');
+ $pattern->getMatrix('foo');
+ trigger_error('get matrix requires no args');
} catch (CairoException $e) {
echo $e->getMessage(), PHP_EOL;
}
@@ -45,8 +34,9 @@ object(CairoMatrix)#%d (0) {
}
object(CairoMatrix)#%d (0) {
}
+bool(false)
object(CairoMatrix)#%d (0) {
}
-CairoPattern::setMatrix() expects exactly 1 parameter, 0 given
-CairoPattern::setMatrix() expects exactly 1 parameter, 2 given
-CairoPattern::setMatrix() expects parameter 1 to be CairoMatrix, integer given
+bool(true)
+bool(false)
+CairoPattern::getMatrix() expects exactly 0 parameters, 1 given
View
1 tests/CairoPattern/getType.phpt
@@ -16,6 +16,7 @@ var_dump($pattern->getType());
try {
$pattern->getType('foo');
+ trigger_error('CairoPattern->getType requires no arguments');
} catch (CairoException $e) {
echo $e->getMessage();
}
View
31 tests/CairoPattern/setMatrix.phpt
@@ -13,17 +13,44 @@ $matrix = new CairoMatrix();
var_dump($matrix);
$pattern->setMatrix($matrix);
+$matrix1 = $pattern->getMatrix();
+
+var_dump($matrix === $matrix1);
+
+$matrix2 = new CairoMatrix(5, 5);
+$pattern->setMatrix($matrix2);
+$matrix1 = $pattern->getMatrix();
+
+var_dump($matrix2 === $matrix1);
try {
$pattern->setMatrix();
+ trigger_error('Set matrix requires one arg');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+
+try {
+ $pattern->setMatrix(1, 1);
+ trigger_error('Set matrix requires only one arg');
} catch (CairoException $e) {
- echo $e->getMessage();
+ echo $e->getMessage(), PHP_EOL;
}
+try {
+ $pattern->setMatrix(1);
+ trigger_error('Set matrix requires instanceof Cairomatrix');
+} catch (CairoException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
?>
--EXPECTF--
object(CairoSolidPattern)#%d (0) {
}
object(CairoMatrix)#%d (0) {
}
-CairoPattern::setMatrix() expects exactly 1 parameter, 0 given
+bool(true)
+bool(true)
+CairoPattern::setMatrix() expects exactly 1 parameter, 0 given
+CairoPattern::setMatrix() expects exactly 1 parameter, 2 given
+CairoPattern::setMatrix() expects parameter 1 to be CairoMatrix, integer given
View
1 tests/CairoPattern/status.phpt
@@ -18,6 +18,7 @@ var_dump($status == CairoStatus::SUCCESS);
try {
$pattern->status('foo');
+ trigger_error('status requires no args');
} catch (CairoException $e) {
echo $e->getMessage();
}
View
15 tests/cairo_constants.phpt
@@ -72,6 +72,20 @@ $cairo_surface_type_constants = array(
'CAIRO_SURFACE_TYPE_QUARTZ_IMAGE',
);
+$cairo_pattern_type_constants = array(
+ 'CAIRO_PATTERN_TYPE_SOLID',
+ 'CAIRO_PATTERN_TYPE_SURFACE',
+ 'CAIRO_PATTERN_TYPE_LINEAR',
+ 'CAIRO_PATTERN_TYPE_RADIAL',
+ );
+
+$cairo_extend_constants = array(
+ 'CAIRO_EXTEND_NONE',
+ 'CAIRO_EXTEND_REPEAT',
+ 'CAIRO_EXTEND_REFLECT',
+ 'CAIRO_EXTEND_PAD',
+ );
+
$cairo_content_constants = array(
'CAIRO_CONTENT_COLOR',
'CAIRO_CONTENT_ALPHA',
@@ -106,6 +120,7 @@ if (in_array('SVG', $surfaces)) {
// merge all the constants together
$constants = array_merge(
$cairo_status_constants,
+ $cairo_extend_constants,
$cairo_surface_type_constants,
$cairo_content_constants,
$cairo_image_format_constants,

0 comments on commit bf7cb09

Please sign in to comment.
Something went wrong with that request. Please try again.