d3_info_handler.test in d3.js 7
File
tests/d3_info_handler.test
View source
<?php
require_once dirname(__FILE__) . '/../includes/D3LibraryInfoProcessor.inc';
require_once dirname(__FILE__) . '/../includes/D3LibraryInfoController.inc';
require_once dirname(__FILE__) . '/../includes/D3DataMapping.inc';
class D3InfoHandlerTest extends DrupalUnitTestCase {
protected $library;
protected $controller;
public static function getInfo() {
return array(
'name' => 'D3 Info Handlers',
'description' => 'Test the library info handlers',
'group' => 'D3',
);
}
public function setUp() {
parent::setUp();
$this
->enableModule('d3');
$this->library['machine name'] = 'simpletest_test_library';
$this->library['simpletest']['rows']['__array_type'] = '2dnnv';
$this->library['simpletest']['rows']['name'] = '{ type: integer }';
$this->library['simpletest']['x_axis_color']['__context'] = 'style_settings';
$this->library['simpletest']['x_axis_title']['field__'] = '{ type: string }';
$this->controller = d3_get_library_info_handler('simpletest');
}
protected function enableModule($name) {
$modules = module_list();
$modules[$name] = $name;
module_list(TRUE, FALSE, FALSE, $modules);
}
function testLibraryInfoController() {
$this->controller
->setLibrary($this->library);
$this
->assertEqual('simpletest_test_library', $this->controller
->machineName());
}
function testLibraryInfoProcessor() {
$this->controller
->setLibrary($this->library);
$this->controller->processor
->process();
$this
->assertNotNull($this->library['simpletest']['rows']['_info']);
$this
->assertEqual($this->library['simpletest']['rows']['_info']['array_type'], '2dnnv');
}
}