Skip to content

Commit

Permalink
Staying in function scope, no need to go object wide
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed Feb 3, 2014
1 parent 3eae10a commit a0174ef
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions Test/Case/CakeRatchetTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ public function all() {

abstract class CakeRatchetTestCase extends CakeTestCase {

private $__cbi = [];

/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();

$this->__cbi = [];

$this->shell = $this->getMock('WebsocketShell', [], [
'out',
]);
Expand All @@ -54,17 +50,18 @@ public function tearDown() {
}

protected function _expectedEventCalls(&$asserts, $events) {
$cbi = [];
foreach ($events as $eventName => $event) {
$count = count($events[$eventName]['callback']);
for ($i = 0; $i < $count; $i++) {
$asserts[$eventName . '_' . $i] = false;
}
$this->__cbi[$eventName] = 0;
$cbi[$eventName] = 0;
$this->eventManager->attach(
function ($event) use (&$events, $eventName, &$asserts) {
$asserts[$eventName . '_' . $this->__cbi[$eventName]] = true;
call_user_func($events[$eventName]['callback'][$this->__cbi[$eventName]], $event);
$this->__cbi[$eventName]++;
function ($event) use (&$events, $eventName, &$asserts, &$cbi) {
$asserts[$eventName . '_' . $cbi[$eventName]] = true;
call_user_func($events[$eventName]['callback'][$cbi[$eventName]], $event);
$cbi[$eventName]++;
},
$eventName
);
Expand Down

0 comments on commit a0174ef

Please sign in to comment.