Updated themes

Updated buildings
Updated shipyard page (ships & defense)
Added Buildings building queue display & cancel build action.
Added research lab
Added navigation block structure
Removed old code
Updated registration
Added files to .gitignore

Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
Gregory PLANCHAT 2011-09-13 12:54:03 +02:00
commit 8f0f7a4d46
147 changed files with 3488 additions and 2468 deletions

View file

@ -0,0 +1,237 @@
<?php
/**
* Test class for Legacies_Object.
* Generated by PHPUnit on 2011-09-01 at 11:24:52.
*/
class Test_Legacies_Empire_Model_BuilderTest extends PHPUnit_Framework_TestCase
{
/**
* @var Legacies_Empire_Model_Planet
*/
protected $_planet = null;
/**
* @var Legacies_Empire_Model_User
*/
protected $_user = null;
protected $_class = 'Legacies_Empire_Model_BuilderAbstract';
protected $_queueItemsData = null;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->_planet = new Legacies_Empire_Model_Planet(array(
'id' => 1,
'id_owner' => 1
));
$this->_user = new Legacies_Empire_Model_User(array(
'id' => 1
));
$this->_planet->setUser($this->_user);
$this->_user->setCurrentPlanet($this->_planet);
$this->_user->setHomePlanet($this->_planet);
$this->_queueItemsData = array(
'IDX0001' => array(
'item_id' => 1,
'level' => 1,
'created_at' => 0,
'updated_at' => 0
),
'IDX0002' => array(
'item_id' => 1,
'level' => 2,
'created_at' => 100,
'updated_at' => 100
),
'IDX0003' => array(
'item_id' => 1,
'level' => 3,
'created_at' => 150,
'updated_at' => 150
)
);
}
protected function _getMockedInstance($planet, $user, $methods = array())
{
$reflector = new ReflectionClass($this->_class);
foreach ($reflector->getMethods() as $method) {
if ($method->isAbstract()) {
$methods[] = $method->getName();
}
}
if (empty($methods)) {
$methods = null;
}
return $this->getMock($this->_class, $methods, array($planet, $user));
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
public function testInit()
{
$stub = $this->getMockBuilder('Legacies_Empire_Model_BuilderAbstract')
->disableOriginalConstructor()
->setMethods(array('init', '_initItem', 'updateQueue', 'appendQueue', 'getResourcesNeeded', 'getBuildingTime'))
->getMock();
$stub->expects($this->once())
->method('init')
->will($this->returnValue($stub));
$stub->expects($this->never())
->method('_serializeQueue')
->will($this->returnValue($stub));
$stub->expects($this->never())
->method('_unserializeQueue')
->will($this->returnValue($stub));
$stub->__construct($this->_planet, $this->_user);
}
public function testSerializingQueue()
{
$items = array(
'IDX0001' => array(
'item_id' => 1,
'level' => 1,
'created_at' => 0,
'updated_at' => 0
),
'IDX0002' => array(
'item_id' => 1,
'level' => 2,
'created_at' => 100,
'updated_at' => 100
),
'IDX0003' => array(
'item_id' => 1,
'level' => 3,
'created_at' => 150,
'updated_at' => 150
)
);
$stub = $this->_getMockedInstance($this->_planet, $this->_user, array('_generateIndex'));
$stub->expects($this->exactly(3))
->method('_initItem')
->will($this->onConsecutiveCalls(
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0001']),
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0002']),
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0003'])
));
$stub->expects($this->exactly(3))
->method('_generateIndex')
->will($this->onConsecutiveCalls(
'IDX0001',
'IDX0002',
'IDX0003'
));
$stub->enqueue($this->_queueItemsData['IDX0001']);
$stub->enqueue($this->_queueItemsData['IDX0002']);
$stub->enqueue($this->_queueItemsData['IDX0003']);
$this->assertEquals(serialize($this->_queueItemsData), $stub->serialize());
}
public function testUnSerializingQueue()
{
$serializedData = serialize($this->_queueItemsData);
$stub = $this->_getMockedInstance($this->_planet, $this->_user, array('_generateIndex'));
$stub->expects($this->exactly(3))
->method('_initItem')
->will($this->onConsecutiveCalls(
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0001']),
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0002']),
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0003'])
));
$stub->expects($this->never())
->method('_generateIndex');
$stub->unserialize($serializedData);
$this->assertAttributeNotEmpty('_queue', $stub);
$this->assertEquals(serialize($this->_queueItemsData), $stub->serialize());
}
public function testUnSerializingQueueWithInvalidData()
{
$serializedData = '';
$stub = $this->_getMockedInstance($this->_planet, $this->_user, array('_generateIndex'));
$stub->expects($this->never())
->method('_initItem');
$stub->expects($this->never())
->method('_generateIndex');
$stub->unserialize($serializedData);
$this->assertAttributeEmpty('_queue', $stub);
$this->assertEquals('a:0:{}', $stub->serialize());
}
public function testInitItemReturningNull()
{
$serializedData = serialize($this->_queueItemsData);
$stub = $this->_getMockedInstance($this->_planet, $this->_user, array('_generateIndex'));
$stub->expects($this->exactly(3))
->method('_initItem')
->will($this->returnValue(null));
$stub->unserialize($serializedData);
$this->assertAttributeEmpty('_queue', $stub);
$this->assertEquals('a:0:{}', $stub->serialize());
}
public function testCheckAvailability()
{
$serializedData = serialize($this->_queueItemsData);
$stub = $this->_getMockedInstance($this->_planet, $this->_user, array('_generateIndex'));
$stub->expects($this->any())
->method('_initItem')
->will($this->onConsecutiveCalls(
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0001'])
));
$this->assertTrue($stub->checkAvailability(Legacies_Empire::ID_BUILDING_METAL_MINE));
$this->assertTrue($stub->checkAvailability(Legacies_Empire::ID_BUILDING_CRISTAL_MINE));
$this->assertTrue($stub->checkAvailability(Legacies_Empire::ID_BUILDING_DEUTERIUM_SYNTHETISER));
$this->assertTrue($stub->checkAvailability(Legacies_Empire::ID_BUILDING_FUSION_REACTOR));
}
}

View file

@ -0,0 +1,205 @@
<?php
/**
* Test class for Legacies_Object.
* Generated by PHPUnit on 2011-09-01 at 11:24:52.
*/
class Test_Legacies_ObjectTest extends PHPUnit_Framework_TestCase
{
/**
* @var Legacies_Object
*/
protected $_object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->_object = new Legacies_Object();
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
/**
* @todo Implement testSetData().
*/
public function testSetData()
{
$this->assertAttributeEmpty('_data', $this->_object);
$this->_object->setData('test', true);
$expected = array('test' => true);
$this->assertAttributeEquals($expected, '_data', $this->_object);
$this->_object->setData('test', 'testing');
$expected = array('test' => 'testing');
$this->assertAttributeEquals($expected, '_data', $this->_object);
}
/**
* @requires testSetData
*/
public function testGetData()
{
$this->_object->setData('test', 'testing');
$this->assertEquals('testing', $this->_object->getData('test'));
$this->_object->setData('test', true);
$this->assertTrue($this->_object->getData('test'));
$this->assertNull($this->_object->getData('testing'));
}
/**
* @requires testSetData
* @requires testGetData
*/
public function testGetAllDatas()
{
$this->_object->setData('test', 'testing');
$expected = array('test' => 'testing');
$this->assertEquals($expected, $this->_object->getAllDatas());
$this->_object->setData('test', true);
$expected = array('test' => true);
$this->assertEquals($expected, $this->_object->getAllDatas());
}
/**
* @requires testSetData
* @requires testGetData
*/
public function testHasData()
{
$this->_object->setData('test', 'testing');
$this->assertTrue($this->_object->hasData('test'));
$this->assertFalse($this->_object->hasData('testing'));
}
/**
* @requires testSetData
*/
public function testAddData()
{
$this->_object->setData('test', 'testing');
$expected = array(
'test' => 'testing',
'testing' => true,
'legacies' => false
);
$this->_object->addData(array(
'testing' => true,
'legacies' => false
));
$this->assertAttributeEquals($expected, '_data', $this->_object);
$expected = array(
'test' => 'legacies',
'testing' => false,
'legacies' => 'Legacies_Object'
);
$this->_object->addData($expected);
$this->assertAttributeEquals($expected, '_data', $this->_object);
}
/**
* @requires testSetData
*/
public function testUnsetData()
{
$this->_object->setData('test', 'testing');
$this->_object->setData('testing', true);
$this->_object->setData('removed', 'me!');
$this->_object->setData('legacies', false);
$expected = array(
'test' => 'testing',
'testing' => true,
'legacies' => false
);
$this->_object->unsetData('removed');
$this->assertAttributeEquals($expected, '_data', $this->_object);
}
/**
* @todo Implement testClearData().
*/
public function testClearData()
{
$this->_object->setData('test', 'testing');
$this->_object->setData('testing', true);
$this->_object->setData('removed', 'me!');
$this->_object->setData('legacies', false);
$expected = array(
'test' => 'testing',
'testing' => true,
'legacies' => false
);
$this->_object->clearData();
$this->assertAttributeEmpty('_data', $this->_object);
}
/**
* @requires testSetData
* @requires testHasData
*/
public function testOffsetExists()
{
$this->_object->setData('test', 'testing');
$this->assertTrue(isset($this->_object['test']));
}
/**
* @requires testSetData
* @requires testGetData
*/
public function testOffsetGet()
{
$this->_object->setData('test', 'testing');
$this->assertEquals('testing', $this->_object['test']);
}
/**
* @requires testGetData
* @requires testSetData
*/
public function testOffsetSet()
{
$this->_object['test'] = 'testing';
$this->assertEquals('testing', $this->_object->getData('test'));
}
/**
* @requires testSetData
* @requires testGetData
*/
public function testOffsetUnset()
{
$this->_object->setData('test', 'testing');
unset($this->_object['test']);
$this->assertAttributeEmpty('_data', $this->_object);
$this->assertNull($this->_object->getData('test'));
}
}

View file

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

View file

@ -0,0 +1,66 @@
<?php
set_include_path(implode(PATH_SEPARATOR, array(
dirname(__DIR__),
get_include_path()
)));
function frameworkAutoload($class) {
include_once str_replace('_', '/', $class) . '.php';
}
spl_autoload_register('frameworkAutoload');
include 'vfsStream/vfsStream.php';
vfsStream::create(array(
'includes' => array(
'application' => array(
'code' => array(
'community' => array(),
'core' => array(),
'libraries' => array(),
'local' => array(),
),
'design' => array(
'layouts' => array(),
'scripts' => array()
)
),
'data' => array(
'combat.php' => '<?php echo ' . var_export(array(), true),
'events.php' => '<?php echo ' . var_export(array(), true),
'fields-alias.php' => '<?php echo ' . var_export(array(), true),
'prices.php' => '<?php echo ' . var_export(array(), true),
'production.php' => '<?php echo ' . var_export(array(), true),
'requirements.php' => '<?php echo ' . var_export(array(), true),
'resources.php' => '<?php echo ' . var_export(array(), true),
'types.php' => '<?php echo ' . var_export(array(), true),
)
),
'config.php' => '<?php echo ' . var_export(array(
'global' => array(
'date' => array(
'timezone' => 'Europe/Paris'
),
'database' => array(
'engine' => 'mysql',
'options' => array(
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'db_xnova'
),
'table_prefix' => 'game_',
),
'layout' => array(
'page' => 'page.php',
'empire' => 'empire.php'
)
)
), true) . ';'
), 'root', 644);
define('ROOT_PATH', vfsStream::url(''));
define('APPLICATION_PATH', vfsStream::url('includes/application'));