forked from ZF-Commons/ZfcBase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update EventProvider and ProvidesEventsForm to call attachDefaultList…
…eners if it exists (Brings both into sync with ZF2's EventManagerAwareTrait) Closes ZF-Commons#80
- Loading branch information
1 parent
2d0e901
commit 84cfe0c
Showing
8 changed files
with
108 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace ZfcBaseTest\EventManager; | ||
|
||
use PHPUnit_Framework_TestCase; | ||
|
||
class EventProviderTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function testSetEventManagerAttachesDefaultListenersWhenSpecified() | ||
{ | ||
$object = new TestAsset\EventProviderWithDefaultListeners(); | ||
$this->assertInstanceOf('Zend\EventManager\EventManagerInterface', $object->getEventManager()); | ||
$this->assertCount(1, $object->getEventManager()->getListeners('foo')); | ||
} | ||
|
||
public function testSetEventManagerBehavesAsNormalWhenNoDefaultListenersSupplied() | ||
{ | ||
$object = new TestAsset\EventProviderWithNoDefaultListeners(); | ||
$this->assertInstanceOf('Zend\EventManager\EventManagerInterface', $object->getEventManager()); | ||
$this->assertCount(0, $object->getEventManager()->getEvents()); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
test/ZfcBaseTest/EventManager/TestAsset/EventProviderWithDefaultListeners.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
namespace ZfcBaseTest\EventManager\TestAsset; | ||
|
||
use ZfcBase\EventManager\EventProvider; | ||
|
||
class EventProviderWithDefaultListeners extends EventProvider | ||
{ | ||
public function attachDefaultListeners() | ||
{ | ||
$this->getEventManager()->attach('foo', function() {}); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
test/ZfcBaseTest/EventManager/TestAsset/EventProviderWithNoDefaultListeners.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
namespace ZfcBaseTest\EventManager\TestAsset; | ||
|
||
use ZfcBase\EventManager\EventProvider; | ||
|
||
class EventProviderWithNoDefaultListeners extends EventProvider | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
test/ZfcBaseTest/Form/TestAsset/ProvidesEventsWithDefaultListeners.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
namespace ZfcBaseTest\Form\TestAsset; | ||
|
||
use ZfcBase\Form\ProvidesEventsForm; | ||
|
||
class ProvidesEventsWithDefaultListeners extends ProvidesEventsForm | ||
{ | ||
public function attachDefaultListeners() | ||
{ | ||
$this->getEventManager()->attach('foo', function() {}); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
test/ZfcBaseTest/Form/TestAsset/ProvidesEventsWithNoDefaultListeners.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
namespace ZfcBaseTest\Form\TestAsset; | ||
|
||
use ZfcBase\Form\ProvidesEventsForm; | ||
|
||
class ProvidesEventsWithNoDefaultListeners extends ProvidesEventsForm | ||
{ | ||
} |