/** * Test registering an OUTPUT pipe to a junction. * <P> * Tests that the OUTPUT pipe is successfully registered and * that the hasPipe and hasOutputPipe methods work. Then tests * that the pipe can be retrieved by name.</P> * <P> * Finally, it removes the registered OUTPUT pipe and tests * that all the previous assertions about it's registration * and accessability via the Junction are no longer true.</P> */ public function testRegisterRetrieveAndRemoveOutputPipe() { // create pipe connected to this test with a pipelistener $pipe = new Pipe(); // create junction $junction = new Junction(); // register the pipe with the junction, giving it a name and direction $registered = $junction->registerPipe('testOutputPipe', Junction::OUTPUT, $pipe); // test assertions $this->assertTrue($pipe instanceof Pipe, "Expecting \$pipe instanceof Pipe"); $this->assertTrue($junction instanceof Junction, "Expecting \$junction instanceof Junction"); $this->assertTrue($registered, "Expecting regsitered pipe"); // assertions about junction methods once input pipe is registered $this->assertTrue($junction->hasPipe('testOutputPipe'), "Expecting junction has pipe"); $this->assertTrue($junction->hasOutputPipe('testOutputPipe'), "Expecting junction has pipe registered as an OUTPUT type"); $this->assertTrue($junction->retrievePipe('testOutputPipe') === $pipe, "Expecting pipe retrieved from junction"); // object equality // now remove the pipe and be sure that it is no longer there (same assertions should be false) $junction->removePipe('testOutputPipe'); $this->assertFalse($junction->hasPipe('testOutputPipe'), "Expecting junction has pipe"); $this->assertFalse($junction->hasOutputPipe('testOutputPipe'), "Expecting junction has pipe registered as an INPUT type"); $this->assertFalse($junction->retrievePipe('testOutputPipe') === $pipe, "Expecting pipe can't be retrieved from junction"); // object equality }