pecl-ev / tests / 02_ev_construct_variation.phpt

--TEST--
Check for constructor and factory methods' behaviour
--FILE--
<?php

$prev_data = "prev_data";
$third_data = "new_data";

// Passing data var to constructor
$loop = new EvLoop(0, $prev_data);
var_dump($loop->data);

// data property read/write
$loop->data = "new data";
var_dump($loop->data);

// rewrite data property with string literal
$loop->data = "new new data";
var_dump($loop->data);

// rewrite data property with a variable
$loop->data = $third_data;
var_dump($loop->data);

// Multiple attempts to create the default loop
$loop2 = EvLoop::defaultLoop();
$loop2 = EvLoop::defaultLoop();
$loop2 = EvLoop::defaultLoop();

// Overwriting previously created loop with the default loop
$loop = EvLoop::defaultLoop();

// Overwriting previously created default loop with new loop
$loop = new EvLoop(Ev::FLAG_AUTO);
// Should be NULL
var_dump($loop->data);
?>
--CLEAN--
--EXPECTF--
string(9) "prev_data"
string(8) "new data"
string(12) "new new data"
string(8) "new_data"

Warning: EvLoop::defaultLoop(): Returning previously created default loop in %s on line %d

Warning: EvLoop::defaultLoop(): Returning previously created default loop in %s on line %d

Warning: EvLoop::defaultLoop(): Returning previously created default loop in %s on line %d
NULL
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.