/** * Tests observer class when initialized by accessor methods. */ public function testObserverAccessors() { // Create observer with null args, then // use accessors to set notification method and context $observer = new Observer('', ''); $observer->setNotifyContext($this); $observer->setNotifyMethod('observerTestMethod'); // create a test event, setting a payload 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', 10); $observer->notifyObserver($note); // test assertions $this->assertTrue($this->observerTestVar == 10, "Expecting observerTestVar = 10"); }