* @license PHP License * @package WB * @subpackage unittest */ /** * Unit Test Event * * Test Event system * * @version 0.1.1 * @package WB * @subpackage unittest */ class TestCaseEventQueue extends UnitTestCase { /** * table * @var WBDatasource_Table */ protected $table; /** * constructor */ public function __construct() { WBClass::load('WBUnitTest_SQLUte' , 'WBEvent_Handler_UnitTest'); WBUnitTest_SQLUte::source(__FILE__, 'construct'); $this->table = WBClass::create('WBDatasource_Table'); } /** * destructor */ public function __destruct() { WBUnitTest_SQLUte::source( __FILE__, 'destruct' ); } /** * check classes */ public function testClasses() { WBClass::load('WBEvent'); $this->assertTrue(class_exists( 'WBEvent', false)); $this->assertTrue(class_exists( 'WBEvent_Queue', false)); $e = WBEvent::create('unittest:0', 'Message', array('data' => 'data'), gmdate('Y-m-d H:i:s')); $this->assertIsA($e, 'WBEvent'); $q0 = WBEvent_Queue::create(); $this->assertIsA($q0, 'WBEvent_Queue'); $q1 = WBEvent_Queue::create(); $this->assertIsA($q1, 'WBEvent_Queue'); $this->assertIdentical($q0, $q1); } public function testEventQueueGetActions() { $q = WBEvent_Queue::create(); $actions = $q->getActions('unittest:0'); $this->assertTrue(empty($actions)); $actions = $q->getActions('unittest:1'); $this->assertEqual(count($actions), 2); $actions = $q->getActions('unittest:2'); $this->assertEqual(count($actions), 2); $actions = $q->getActions('unittest:3'); $this->assertEqual(count($actions), 2); } public function testEventTriggerAny() { $events = $this->table->count('eventqueue'); WBEvent::trigger('unittest:1', 'Message'); ++$events; ++$events; $this->assertTrue($events == $this->table->count('eventqueue')); WBEvent::trigger('unittest:2', 'Message'); ++$events; ++$events; $this->assertTrue($events == $this->table->count('eventqueue')); WBEvent::trigger('unittest:3', 'Message'); $list = WBEvent_Handler_UnitTest::getProclist('now'); $this->assertTrue(is_array($list)); $this->assertTrue(in_array('unittest:3', $list)); ++$events; $this->assertTrue($events == $this->table->count('eventqueue')); WBEvent::trigger('unittest:4', 'Message'); ++$events; $this->assertTrue($events == $this->table->count('eventqueue')); $list = WBEvent_Handler_UnitTest::getProclist('now'); $this->assertTrue(is_array($list)); $this->assertTrue(in_array('unittest:4', $list)); WBEvent::trigger('unittest:5', 'Message'); ++$events; ++$events; $this->assertTrue($events == $this->table->count('eventqueue')); WBEvent::trigger('unittest:6', 'Message'); ++$events; $this->assertTrue($events == $this->table->count('eventqueue')); WBEvent::trigger('unittest:7', 'Message'); $this->assertTrue($events == $this->table->count('eventqueue')); } public function testEventTrigger() { } } ?>