Refactored to 2 namespaces: Wootook & Legacies

Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
Gregory PLANCHAT 2011-10-04 19:57:00 +02:00
commit ec7e40e1aa
1004 changed files with 4808 additions and 2971 deletions

View file

@ -0,0 +1,119 @@
<?php
class Test_LegaciesTest
extends PHPUnit_Framework_TestCase
{
protected function tearDown()
{
Wootook::clearAllListeners();
}
public function nonStaticListener($observer)
{
$observer->setData('success', true);
}
public static function staticListener($observer)
{
$observer->setData('success', true);
}
public function testRegisteringNonStaticEvent()
{
Wootook::registerListener('testing', array($this, 'nonStaticListener'));
$observer = Wootook::dispatchEvent('testing', array('success' => false));
$this->assertInstanceOf('Legacies_Core_Event', $observer);
$this->assertTrue($observer->getData('success'));
}
public function testRegisteringStaticEvent()
{
Wootook::registerListener('testing', array(get_class($this), 'staticListener'));
$observer = Wootook::dispatchEvent('testing', array('success' => false));
$this->assertInstanceOf('Legacies_Core_Event', $observer);
$this->assertTrue($observer->getData('success'));
}
public function testDispatchNonExistingEvent()
{
$observer = Wootook::dispatchEvent('testing', array('success' => true));
$this->assertInstanceOf('Legacies_Core_Event', $observer);
$this->assertTrue($observer->getData('success'));
}
/**
* @depends testRegisteringNonStaticEvent
*/
public function testUnregisteringNonStaticEvent()
{
Wootook::registerListener('testing', array($this, 'nonStaticListener'));
Wootook::clearEventListeners('testing');
$observer = Wootook::dispatchEvent('testing', array('success' => false));
$this->assertInstanceOf('Legacies_Core_Event', $observer);
$this->assertFalse($observer->getData('success'));
}
/**
* @depends testRegisteringStaticEvent
*/
public function testUnregisteringStaticEvent()
{
Wootook::registerListener('testing', array(get_class($this), 'staticListener'));
Wootook::clearEventListeners('testing');
$observer = Wootook::dispatchEvent('testing', array('success' => false));
$this->assertInstanceOf('Legacies_Core_Event', $observer);
$this->assertFalse($observer->getData('success'));
}
public function testGetSession()
{
$this->markTestSkipped('Sessions could not be tested in CLI.');
$this->assertInstanceOf('Legacies_Core_Model_Session', Wootook::getSession('test'));
}
public function testGetTranslator()
{
$this->assertInstanceOf('Legacies_Core_Model_Translator', Wootook::getTranslator('test'));
$this->assertInstanceOf('Legacies_Core_Model_Translator', Wootook::getTranslator());
}
public function testTranslate()
{
$this->assertEquals('My testing message!', Wootook::translate('test', 'My %s message!', array('testing')));
}
public function testTranslateGettextStyle()
{
$this->assertEquals('My testing message!', Wootook::__('My %s message!', 'testing'));
}
public function testSetDefaultLocale()
{
Wootook::setDefaultLocale('test');
$this->assertAttributeEquals('test', '_defaultLocale', 'Beyond');
}
/**
*
* @requires testSetDefaultLocale
*/
public function testGetDefaultLocale()
{
Wootook::setDefaultLocale('test');
$this->assertEquals('test', Wootook::getDefaultLocale());
}
}