// Create a Callback. $callback = new \Happen\Callback('\\Happen\\Test\\onJohn'); // Add the Callback to a child eventspace $child_ev_space = $root_ev_space->addChild($child_name, array($callback)); // Check a new Eventspace was created. $tf->assertTrue($child_ev_space instanceof \Happen\Eventspace); // Check the Eventspace name was set. $tf->assertEquals($child_ev_space->name, $child_name); // Check the Eventspace parent was set. $tf->assertIdentical($child_ev_space->parent, $root_ev_space); // Check the callback was added to the child Eventspace. $tf->assertInArray($callback, $child_ev_space->callbacks); $tf->assertInArray($callback, $child_ev_space->getCallbacks()); // Check the callback is removed from the child. $child_ev_space->removeCallback($callback); $tf->assertNotInArray($callback, $child_ev_space->getCallbacks()); // Check the root Eventspace sees the child. $tf->assertTrue($root_ev_space->hasChild($child_name)); // Check the child is removed from the root. $root_ev_space->removeChild($child_name); $tf->assertFalse($root_ev_space->hasChild($child_name)); }); $tf->test('Add deep child eventspace with callbacks', function ($tf) { // Get the root Eventspace. $child_name = 'john'; $grandchild_name = 'john:lucy'; $root_ev_space = $tf->data->ev_space; // Create Callbacks. $callback_john = new \Happen\Callback('\\Happen\\Test\\onJohn'); $callback_john_lucy = new \Happen\Callback('\\Happen\\Test\\onJohnLucy'); // Create a deep namespace.