svn: /pecl/cairo/trunk/tests/CairoSurface/ CairoSubSurface/__construct.phpt cairo_surface_create_for_rectangle.phpt

From: Date: Wed, 28 Dec 2011 17:31:12 +0000
Subject: svn: /pecl/cairo/trunk/tests/CairoSurface/ CairoSubSurface/__construct.phpt cairo_surface_create_for_rectangle.phpt
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-17420@lists.php.net to get a copy of this message
mgdm Wed, 28 Dec 2011 17:31:12 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=321482 Log: Add tests for CairoSubSurface Changed paths: A pecl/cairo/trunk/tests/CairoSurface/CairoSubSurface/ A pecl/cairo/trunk/tests/CairoSurface/CairoSubSurface/__construct.phpt A pecl/cairo/trunk/tests/CairoSurface/cairo_surface_create_for_rectangle.phpt Added: pecl/cairo/trunk/tests/CairoSurface/CairoSubSurface/__construct.phpt =================================================================== --- pecl/cairo/trunk/tests/CairoSurface/CairoSubSurface/__construct.phpt (rev 0) +++ pecl/cairo/trunk/tests/CairoSurface/CairoSubSurface/__construct.phpt 2011-12-28 17:31:12 UTC (rev 321482) @@ -0,0 +1,28 @@ +--TEST-- +new CairoSubSurface [ __construct method ] +--SKIPIF-- +<?php +if(!extension_loaded('cairo')) die('skip - Cairo extension not available'); +?> +--FILE-- +<?php +class test extends CairoSubSurface {} + +class test2 extends CairoSubSurface { + public function __construct() {} +} + +try { + $surface = new test(); + echo 'Attempting to use constructor should throw an exception'; +} catch (CairoException $e) { + echo $e->getMessage(); +} + +$surface = new test2(); +$surface->finish(); +echo 'First call to any method should throw a fatal error'; +?> +--EXPECTF-- +CairoSubSurface cannot be constructed +Fatal error: Internal surface object missing in test2 wrapper, you must call parent::__construct in extended classes in %s on line %d Property changes on: pecl/cairo/trunk/tests/CairoSurface/CairoSubSurface/__construct.phpt ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Added: pecl/cairo/trunk/tests/CairoSurface/cairo_surface_create_for_rectangle.phpt =================================================================== --- pecl/cairo/trunk/tests/CairoSurface/cairo_surface_create_for_rectangle.phpt (rev 0) +++ pecl/cairo/trunk/tests/CairoSurface/cairo_surface_create_for_rectangle.phpt 2011-12-28 17:31:12 UTC (rev 321482) @@ -0,0 +1,54 @@ +--TEST-- +cairo_surface_create_for_rectangle () 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); + +var_dump(cairo_surface_create_for_rectangle($surface, 0, 0, 25, 25)); + +// 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 5 +cairo_surface_create_for_rectangle (); +cairo_surface_create_for_rectangle ($surface); +cairo_surface_create_for_rectangle ($surface, 1); +cairo_surface_create_for_rectangle ($surface, 1, 1); +cairo_surface_create_for_rectangle ($surface, 1, 1, 1, 1); + +// check arg types, should be surface object, int int, int +cairo_surface_create_for_rectangle (1, 1, 1, 1); +cairo_surface_create_for_rectangle ($surface, array(), 1, 1); +cairo_surface_create_for_rectangle ($surface, 1, array(), 1); +cairo_surface_create_for_rectangle ($surface, 1, 1, array()); +?> +--EXPECTF-- +object(CairoImageSurface)#1 (0) { +} +object(CairoSubSurface)#2 (0) { +} + +Warning: cairo_surface_create_for_rectangle() expects exactly 5 parameters, 0 given in %s on line %d + +Warning: cairo_surface_create_for_rectangle() expects exactly 5 parameters, 1 given in %s on line %d + +Warning: cairo_surface_create_for_rectangle() expects exactly 5 parameters, 2 given in %s on line %d + +Warning: cairo_surface_create_for_rectangle() expects exactly 5 parameters, 3 given in %s on line %d +CAUGHT ERROR: Argument 1 passed to cairo_surface_create_for_rectangle() must be an instance of CairoSurface, integer given + +Warning: cairo_surface_create_for_rectangle() expects exactly 5 parameters, 4 given in %s on line %d + +Warning: cairo_surface_create_for_rectangle() expects exactly 5 parameters, 4 given in %s on line %d + +Warning: cairo_surface_create_for_rectangle() expects exactly 5 parameters, 4 given in %s on line %d + +Warning: cairo_surface_create_for_rectangle() expects exactly 5 parameters, 4 given in %s on line %d Property changes on: pecl/cairo/trunk/tests/CairoSurface/cairo_surface_create_for_rectangle.phpt ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native

« previous php.pecl.cvs (#17420) next »