setName("Just a name"); $user->setName("Some new name"); $userObserver = new UserObserver(); $user->attach($userObserver); /** After creating a new instance of UserObserver::class * and attached it to User::class instance, * these names will be added to the log of names */ $user->setName("Another new name"); $user->setName("Once again new name"); $user->setName("Possibly other new name"); $this->assertEquals( ["Another new name", "Once again new name", "Possibly other new name"], $userObserver->getNamesLog() ); } }