Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for tests #38

Open
wants to merge 10 commits into
base: php7
Choose a base branch
from
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion src/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ PHP_METHOD(CairoContext, __construct)
cairo_context_object *context_object;
cairo_surface_object *surface_object;

if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "|o", &surface_zval) == FAILURE) {
if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "o", &surface_zval) == FAILURE) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/image_surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ PHP_METHOD(CairoImageSurface, createFromPng)
} else if(Z_TYPE_P(stream_zval) == IS_RESOURCE) {
php_stream_from_zval(stream, stream_zval);
} else {
zend_throw_exception(ce_cairo_exception, "CairoImageSurface::createFromPng() expects parameter 1 to be a string or a stream resource", 0);
zend_throw_exception(ce_cairo_exception, "Cairo\\Surface\\Image::createFromPng() expects parameter 1 to be a string or a stream resource", 0);
return;
}

Expand Down
8 changes: 4 additions & 4 deletions src/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ PHP_METHOD(CairoMatrix, __construct)
/* read defaults from object */
double xx = cairo_matrix_get_property_value(getThis(), "xx");
double yx = cairo_matrix_get_property_value(getThis(), "yx");
double xy = cairo_matrix_get_property_value(getThis(), "xy");
double xy = cairo_matrix_get_property_value(getThis(), "xy");
double yy = cairo_matrix_get_property_value(getThis(), "yy");
double x0 = cairo_matrix_get_property_value(getThis(), "x0");
double x0 = cairo_matrix_get_property_value(getThis(), "x0");
double y0 = cairo_matrix_get_property_value(getThis(), "y0");

/* overwrite with constructor if desired */
Expand Down Expand Up @@ -658,11 +658,11 @@ PHP_MINIT_FUNCTION(cairo_matrix)
ce.create_object = cairo_matrix_create_object;
ce_cairo_matrix = zend_register_internal_class(&ce);

zend_declare_property_long(ce_cairo_matrix, "xx", sizeof("xx")-1, 1, ZEND_ACC_PUBLIC);
zend_declare_property_long(ce_cairo_matrix, "xx", sizeof("xx")-1, 0, ZEND_ACC_PUBLIC);
zend_declare_property_long(ce_cairo_matrix, "xy", sizeof("xy")-1, 0, ZEND_ACC_PUBLIC);
zend_declare_property_long(ce_cairo_matrix, "x0", sizeof("x0")-1, 0, ZEND_ACC_PUBLIC);
zend_declare_property_long(ce_cairo_matrix, "yx", sizeof("yx")-1, 0, ZEND_ACC_PUBLIC);
zend_declare_property_long(ce_cairo_matrix, "yy", sizeof("yy")-1, 1, ZEND_ACC_PUBLIC);
zend_declare_property_long(ce_cairo_matrix, "yy", sizeof("yy")-1, 0, ZEND_ACC_PUBLIC);
zend_declare_property_long(ce_cairo_matrix, "y0", sizeof("y0")-1, 0, ZEND_ACC_PUBLIC);

return SUCCESS;
Expand Down
12 changes: 10 additions & 2 deletions src/php_cairo_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
#include <php.h>
#include <cairo.h>

#if defined(CAIRO_HAS_QUARTZ_FONT)
#include <cairo-quartz.h>
#include <ApplicationServices/ApplicationServices.h>
#endif

extern zend_class_entry *ce_cairo_exception;
extern zend_class_entry *ce_cairo_status;
extern zend_class_entry *ce_cairo_matrix;
Expand Down Expand Up @@ -117,9 +122,12 @@ extern cairo_status_t php_cairo_read_func(void *closure, const unsigned char *da
/* Font + FontFace */
typedef struct _cairo_font_face_object {
cairo_font_face_t *font_face;
stream_closure *closure;
#if defined(CAIRO_HAS_QUARTZ_FONT)
CGFontRef quartzref;
#endif
stream_closure *closure;
cairo_user_data_key_t key;
zend_object std;
zend_object std;
} cairo_font_face_object;

extern zend_object* cairo_font_face_create_object(zend_class_entry *ce);
Expand Down
6 changes: 5 additions & 1 deletion src/quartz_font.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#include "php_cairo_internal.h"

#if defined(CAIRO_HAS_QUARTZ_FONT)

#include <cairo-quartz.h>
#include <ApplicationServices/ApplicationServices.h>

zend_class_entry *ce_cairo_quartzfont;
zend_class_entry *ce_cairo_quartzatsufontnamecode;
zend_class_entry *ce_cairo_quartzatsufontnameplatform;
Expand Down Expand Up @@ -115,7 +119,7 @@ PHP_METHOD(CairoQuartzFontFace, createForCgfont)
/* {{{ cairo_quartz_font_methods[] */
const zend_function_entry cairo_quartz_font_methods[] = {
PHP_ME(CairoQuartzFontFace, createForCgfont, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(CairoQuartzFontFace, createForAtsuiFontId, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(CairoQuartzFontFace, createForAtsuFontId, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
ZEND_FE_END
};
/* }}} */
Expand Down
2 changes: 1 addition & 1 deletion src/region.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "php_cairo.h"

zend_class_entry *ce_cairo_region;
zend_class_entry *ce_cairo_rectangle;
extern zend_class_entry *ce_cairo_rectangle;
zend_class_entry *ce_cairo_region_overlap;

static zend_object_handlers cairo_region_object_handlers;
Expand Down
2 changes: 1 addition & 1 deletion src/svg_surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ PHP_METHOD(CairoSvgSurface, __construct)
} else if(Z_TYPE_P(stream_zval) == IS_RESOURCE) {
php_stream_from_zval(stream, stream_zval);
} else {
zend_throw_exception(ce_cairo_exception, "CairoSvgSurface::__construct() expects parameter 1 to be null, a string, or a stream resource", 0);
zend_throw_exception(ce_cairo_exception, "Cairo\\Surface\\Svg::__construct() expects parameter 1 to be null, a string, or a stream resource", 0);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Cairo/availableFonts.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var_dump($fonts[0]);
try {
Cairo::availableFonts('foo');
trigger_error('Cairo::availableFonts should take no arguments');
} catch (CairoException $e) {
} catch (TypeError $e) {
echo $e->getMessage(), PHP_EOL;
}
?>
Expand Down
2 changes: 1 addition & 1 deletion tests/Cairo/availableSurfaces.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var_dump($surfaces[0]);
try {
Cairo::availableSurfaces('foo');
trigger_error('Cairo::availableSurfaces should take no arguments');
} catch (CairoException $e) {
} catch (TypeError $e) {
echo $e->getMessage(), PHP_EOL;
}
?>
Expand Down
16 changes: 8 additions & 8 deletions tests/Cairo/statusToString.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ if(!extension_loaded('cairo')) die('skip - Cairo extension not available');
?>
--FILE--
<?php
$surface = new CairoImageSurface(CAIRO_FORMAT_ARGB32, 50, 50);
$surface = new Cairo\Surface\Image(CAIRO_FORMAT_ARGB32, 50, 50);
var_dump($surface);

$context = new CairoContext($surface);
$context = new Cairo\Context($surface);
var_dump($context);

var_dump(Cairo::statusToString($context->status()));
Expand All @@ -18,32 +18,32 @@ var_dump(Cairo::statusToString($context->status()));
try {
Cairo::statusToString();
trigger_error('Cairo::statusToString should take 1 argument');
} catch (CairoException $e) {
} catch (TypeError $e) {
echo $e->getMessage(), PHP_EOL;
}

/* Wrong number args 2*/
try {
Cairo::statusToString(1, 1);
trigger_error('Cairo::statusToString should take 1 argument');
} catch (CairoException $e) {
} catch (TypeError $e) {
echo $e->getMessage(), PHP_EOL;
}

/* Wrong arg type*/
try {
Cairo::statusToString(array());
trigger_error('Cairo::statusToString arg 1 must be scalar (int)');
} catch (CairoException $e) {
} catch (TypeError $e) {
echo $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
object(Cairo\Surface\Image)#%d (0) {
}
object(CairoContext)#%d (0) {
object(Cairo\Context)#%d (0) {
}
string(21) "no error has occurred"
Cairo::statusToString() expects exactly 1 parameter, 0 given
Cairo::statusToString() expects exactly 1 parameter, 2 given
Cairo::statusToString() expects parameter 1 to be long, array given
Cairo::statusToString() expects parameter 1 to be int, array given
2 changes: 1 addition & 1 deletion tests/Cairo/versionString.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var_dump($version);
try {
Cairo::versionString('foo');
trigger_error('Cairo::versionString should take no arguments');
} catch (CairoException $e) {
} catch (TypeError $e) {
echo $e->getMessage(), PHP_EOL;
}
?>
Expand Down
24 changes: 12 additions & 12 deletions tests/CairoContext/Paths/appendPath.phpt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
--TEST--
CairoContext->appendPath() method
Cairo\Context->appendPath() method
--SKIPIF--
<?php
if(!extension_loaded('cairo')) die('skip - Cairo extension not available');
?>
--FILE--
<?php
$surface = new CairoImageSurface(CairoFormat::ARGB32, 50, 50);
$surface = new Cairo\Surface\Image(Cairo\Surface\ImageFormat::ARGB32, 50, 50);
var_dump($surface);

$context = new CairoContext($surface);
$context = new Cairo\Context($surface);
var_dump($context);

$path = $context->copyPath();
Expand All @@ -21,33 +21,33 @@ $context->appendPath($path);
try {
$context->appendPath();
trigger_error('appendPath requires 0 args');
} catch (CairoException $e) {
} catch (TypeError $e) {
echo $e->getMessage(), PHP_EOL;
}

/* Wrong number args - expects 1 */
try {
$context->appendPath($path, 1);
trigger_error('appendPath requires 0 args');
} catch (CairoException $e) {
} catch (TypeError $e) {
echo $e->getMessage(), PHP_EOL;
}

/* incorrect args, expects cairopath*/
try {
$context->appendPath(1);
trigger_error('appendPath requires 0 args');
} catch (CairoException $e) {
} catch (TypeError $e) {
echo $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
object(Cairo\Surface\Image)#%d (0) {
}
object(CairoContext)#%d (0) {
object(Cairo\Context)#%d (0) {
}
object(CairoPath)#%d (0) {
object(Cairo\Path)#%d (0) {
}
CairoContext::appendPath() expects exactly 1 parameter, 0 given
CairoContext::appendPath() expects exactly 1 parameter, 2 given
CairoContext::appendPath() expects parameter 1 to be CairoPath, integer given
Cairo\Context::appendPath() expects exactly 1 parameter, 0 given
Cairo\Context::appendPath() expects exactly 1 parameter, 2 given
Cairo\Context::appendPath() expects parameter 1 to be Cairo\Path, int given
Loading