/** * Tests observer class when initialized by constructor. */ public function testObserverConstructor() { // Create observer passing in notification method and context $observer = new Observer('observerTestMethod', $this); // create a test note, setting a body value and notify // the observer with it. since the observer is this class // and the notification method is observerTestMethod, // successful notification will result in our local // observerTestVar being set to the value we pass in // on the note body. $note = new Notification('ObserverTestNote', 5); $observer->notifyObserver($note); // test assertions $this->assertTrue($this->observerTestVar == 5, "Expecting observerTestVar = 5"); }