Skip to content

Commit 2af532c

Browse files
committed
Fix observer attach/detach tests
1 parent db7dab5 commit 2af532c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Behavioral/Observer/Tests/ObserverTest.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,20 @@ public function testNotify()
3636
public function testAttachDetach()
3737
{
3838
$subject = new User();
39-
$this->assertAttributeEmpty('observers', $subject);
39+
$reflection = new \ReflectionProperty($subject, 'observers');
40+
41+
$reflection->setAccessible(true);
42+
/** @var \SplObjectStorage $observers */
43+
$observers = $reflection->getValue($subject);
44+
45+
$this->assertInstanceOf('SplObjectStorage', $observers);
46+
$this->assertFalse($observers->contains($this->observer));
47+
4048
$subject->attach($this->observer);
41-
$this->assertAttributeNotEmpty('observers', $subject);
49+
$this->assertTrue($observers->contains($this->observer));
50+
4251
$subject->detach($this->observer);
43-
$this->assertAttributeEmpty('observers', $subject);
52+
$this->assertFalse($observers->contains($this->observer));
4453
}
4554

4655
/**

0 commit comments

Comments
 (0)