Skip to content

Commit

Permalink
More context tests
Browse files Browse the repository at this point in the history
  • Loading branch information
auroraeosrose committed Jul 5, 2009
1 parent f6f4bbd commit 2d2b25e
Show file tree
Hide file tree
Showing 35 changed files with 1,483 additions and 9 deletions.
42 changes: 42 additions & 0 deletions tests/CairoContext/cairo_get_fill_rule.phpt
@@ -0,0 +1,42 @@
--TEST--
cairo_get_fill_rule() 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);

$context = cairo_create($surface);
var_dump($context);

var_dump(cairo_get_fill_rule($context));

// 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);

// check number of args - should accept ONLY 1
cairo_get_fill_rule();
cairo_get_fill_rule($context, 1);

// check arg types, should be context object
cairo_get_fill_rule(1);
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
}
object(CairoContext)#%d (0) {
}
int(0)

Warning: cairo_get_fill_rule() expects exactly 1 parameter, 0 given in %s on line %d

Warning: cairo_get_fill_rule() expects exactly 1 parameter, 2 given in %s on line %d
CAUGHT ERROR: Argument 1 passed to cairo_get_fill_rule() must be an instance of CairoContext, integer given

Warning: cairo_get_fill_rule() expects parameter 1 to be CairoContext, integer given in %s on line %d
42 changes: 42 additions & 0 deletions tests/CairoContext/cairo_get_line_cap.phpt
@@ -0,0 +1,42 @@
--TEST--
cairo_get_line_cap() 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);

$context = cairo_create($surface);
var_dump($context);

var_dump(cairo_get_line_cap($context));

// 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);

// check number of args - should accept ONLY 1
cairo_get_line_cap();
cairo_get_line_cap($context, 1);

// check arg types, should be context object
cairo_get_line_cap(1);
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
}
object(CairoContext)#%d (0) {
}
int(0)

Warning: cairo_get_line_cap() expects exactly 1 parameter, 0 given in %s on line %d

Warning: cairo_get_line_cap() expects exactly 1 parameter, 2 given in %s on line %d
CAUGHT ERROR: Argument 1 passed to cairo_get_line_cap() must be an instance of CairoContext, integer given

Warning: cairo_get_line_cap() expects parameter 1 to be CairoContext, integer given in %s on line %d
42 changes: 42 additions & 0 deletions tests/CairoContext/cairo_get_line_join.phpt
@@ -0,0 +1,42 @@
--TEST--
cairo_get_line_join() 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);

$context = cairo_create($surface);
var_dump($context);

var_dump(cairo_get_line_join($context));

// 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);

// check number of args - should accept ONLY 1
cairo_get_line_join();
cairo_get_line_join($context, 1);

// check arg types, should be context object
cairo_get_line_join(1);
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
}
object(CairoContext)#%d (0) {
}
int(0)

Warning: cairo_get_line_join() expects exactly 1 parameter, 0 given in %s on line %d

Warning: cairo_get_line_join() expects exactly 1 parameter, 2 given in %s on line %d
CAUGHT ERROR: Argument 1 passed to cairo_get_line_join() must be an instance of CairoContext, integer given

Warning: cairo_get_line_join() expects parameter 1 to be CairoContext, integer given in %s on line %d
42 changes: 42 additions & 0 deletions tests/CairoContext/cairo_get_line_width.phpt
@@ -0,0 +1,42 @@
--TEST--
cairo_get_line_width() 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);

$context = cairo_create($surface);
var_dump($context);

var_dump(cairo_get_line_width($context));

// 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);

// check number of args - should accept ONLY 1
cairo_get_line_width();
cairo_get_line_width($context, 1);

// check arg types, should be context object
cairo_get_line_width(1);
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
}
object(CairoContext)#%d (0) {
}
float(2)

Warning: cairo_get_line_width() expects exactly 1 parameter, 0 given in %s on line %d

Warning: cairo_get_line_width() expects exactly 1 parameter, 2 given in %s on line %d
CAUGHT ERROR: Argument 1 passed to cairo_get_line_width() must be an instance of CairoContext, integer given

Warning: cairo_get_line_width() expects parameter 1 to be CairoContext, integer given in %s on line %d
42 changes: 42 additions & 0 deletions tests/CairoContext/cairo_get_miter_limit.phpt
@@ -0,0 +1,42 @@
--TEST--
cairo_get_miter_limit() 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);

$context = cairo_create($surface);
var_dump($context);

var_dump(cairo_get_miter_limit($context));

// 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);

// check number of args - should accept ONLY 1
cairo_get_miter_limit();
cairo_get_miter_limit($context, 1);

// check arg types, should be context object
cairo_get_miter_limit(1);
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
}
object(CairoContext)#%d (0) {
}
float(10)

Warning: cairo_get_miter_limit() expects exactly 1 parameter, 0 given in %s on line %d

Warning: cairo_get_miter_limit() expects exactly 1 parameter, 2 given in %s on line %d
CAUGHT ERROR: Argument 1 passed to cairo_get_miter_limit() must be an instance of CairoContext, integer given

Warning: cairo_get_miter_limit() expects parameter 1 to be CairoContext, integer given in %s on line %d
42 changes: 42 additions & 0 deletions tests/CairoContext/cairo_get_operator.phpt
@@ -0,0 +1,42 @@
--TEST--
cairo_get_operator() 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);

$context = cairo_create($surface);
var_dump($context);

var_dump(cairo_get_operator($context));

// 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);

// check number of args - should accept ONLY 1
cairo_get_operator();
cairo_get_operator($context, 1);

// check arg types, should be context object
cairo_get_operator(1);
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
}
object(CairoContext)#%d (0) {
}
int(2)

Warning: cairo_get_operator() expects exactly 1 parameter, 0 given in %s on line %d

Warning: cairo_get_operator() expects exactly 1 parameter, 2 given in %s on line %d
CAUGHT ERROR: Argument 1 passed to cairo_get_operator() must be an instance of CairoContext, integer given

Warning: cairo_get_operator() expects parameter 1 to be CairoContext, integer given in %s on line %d
42 changes: 42 additions & 0 deletions tests/CairoContext/cairo_get_tolerance.phpt
@@ -0,0 +1,42 @@
--TEST--
cairo_get_tolerance() 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);

$context = cairo_create($surface);
var_dump($context);

var_dump(cairo_get_tolerance($context));

// 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);

// check number of args - should accept ONLY 1
cairo_get_tolerance();
cairo_get_tolerance($context, 1);

// check arg types, should be context object
cairo_get_tolerance(1);
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
}
object(CairoContext)#%d (0) {
}
float(0.1)

Warning: cairo_get_tolerance() expects exactly 1 parameter, 0 given in %s on line %d

Warning: cairo_get_tolerance() expects exactly 1 parameter, 2 given in %s on line %d
CAUGHT ERROR: Argument 1 passed to cairo_get_tolerance() must be an instance of CairoContext, integer given

Warning: cairo_get_tolerance() expects parameter 1 to be CairoContext, integer given in %s on line %d
54 changes: 54 additions & 0 deletions tests/CairoContext/cairo_in_fill.phpt
@@ -0,0 +1,54 @@
--TEST--
cairo_in_fill() 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);

$context = cairo_create($surface);
var_dump($context);

var_dump(cairo_in_fill($context, 1, 1));

// 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);

// check number of args - should accept 3
cairo_in_fill();
cairo_in_fill($context);
cairo_in_fill($context, 1);
cairo_in_fill($context, 1, 1, 1);

// check arg types, should be int
cairo_in_fill(1, 1, 1);
cairo_in_fill($context, array(), 1);
cairo_in_fill($context, 1, array());
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
}
object(CairoContext)#%d (0) {
}
bool(false)

Warning: cairo_in_fill() expects exactly 3 parameters, 0 given in %s on line %d

Warning: cairo_in_fill() expects exactly 3 parameters, 1 given in %s on line %d

Warning: cairo_in_fill() expects exactly 3 parameters, 2 given in %s on line %d

Warning: cairo_in_fill() expects exactly 3 parameters, 4 given in %s on line %d
CAUGHT ERROR: Argument 1 passed to cairo_in_fill() must be an instance of CairoContext, integer given

Warning: cairo_in_fill() expects parameter 1 to be CairoContext, integer given in %s on line %d

Warning: cairo_in_fill() expects parameter 2 to be double, array given in %s on line %d

Warning: cairo_in_fill() expects parameter 3 to be double, array given in %s on line %d

0 comments on commit 2d2b25e

Please sign in to comment.