blob: a8bc8fd05f4d71b4eaf9c22351c62975bd674f23 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
<?php
/**
* Phergie
*
* PHP version 5
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.
* It is also available through the world-wide-web at this URL:
* http://phergie.org/license
*
* @category Phergie
* @package Phergie
* @author Phergie Development Team <team@phergie.org>
* @copyright 2008-2010 Phergie Development Team (http://phergie.org)
* @license http://phergie.org/license New BSD License
* @link http://pear.phergie.org/package/Phergie
*/
require_once(dirname(__FILE__) . '/TestCase.php');
/**
* Unit test suite for Pherge_Plugin_Pong.
*
* @category Phergie
* @package Phergie_Tests
* @author Phergie Development Team <team@phergie.org>
* @license http://phergie.org/license New BSD License
* @link http://pear.phergie.org/package/Phergie
*/
class Phergie_Plugin_PongTest extends Phergie_Plugin_TestCase
{
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->setPlugin(new Phergie_Plugin_Pong);
}
/**
* Test that when a ping is received, a Phergie_Event_Command::TYPE_PONG
* is set to the handler
*
* @event Phergie_Event_Command::TYPE_PING
*/
public function testOnPing()
{
$this->plugin->onPing();
$this->assertHasEvent(Phergie_Event_Command::TYPE_PONG);
}
/**
* Test that when a ping is received, a Phergie_Event_Command::TYPE_PONG
* is set to the handler
*
* @event Phergie_Event_Command::TYPE_PING
*/
public function testOnPingResponseArguement()
{
$this->plugin->onPing();
$this->assertHasEvent(Phergie_Event_Command::TYPE_PONG);
$events = $this->getResponseEvents(Phergie_Event_Command::TYPE_PONG);
$this->assertTrue(count($events) === 1, 'Assert that only one pong is emitted');
$this->assertEventEmitter(current($events),
$this->plugin,
'Assert that the tested plugin emitted the event');
}
}
|