/** * Tests register, exists and unregisrer */ public function testCanRegisterType() { $service = new \Elgg\WidgetsService(array($this, 'elgg_set_config')); $this->assertFalse($service->validateType('widget_type')); $this->assertFalse($service->validateType('not_registered_widget')); $this->assertTrue($service->registerType(\Elgg\WidgetDefinition::factory(['id' => 'widget_type', 'name' => 'Widget name1', 'description' => 'Widget description1']))); $this->assertTrue($service->registerType(\Elgg\WidgetDefinition::factory(['id' => 'widget_type_con', 'name' => 'Widget name2', 'description' => 'Widget description2', 'context' => ['dashboard', 'profile']]))); $this->assertTrue($service->registerType(\Elgg\WidgetDefinition::factory(['id' => 'widget_type_mul', 'name' => 'Widget name3', 'description' => 'Widget description3', 'context' => ['all', 'settings'], 'multiple' => true]))); $this->assertTrue($service->registerType(\Elgg\WidgetDefinition::factory(['id' => 'widget_type_con_mul', 'name' => 'Widget name4', 'description' => 'Widget description4', 'context' => ['dashboard', 'settings'], 'multiple' => true]))); //overwrite $this->assertTrue($service->registerType(\Elgg\WidgetDefinition::factory(['id' => 'widget_type_con_mul', 'name' => 'Widget name5', 'description' => 'Widget description5', 'context' => ['dashboard', 'settings'], 'multiple' => true]))); $this->assertTrue($service->validateType('widget_type')); $this->assertTrue($service->validateType('widget_type_con')); $this->assertTrue($service->validateType('widget_type_mul')); $this->assertTrue($service->validateType('widget_type_con_mul')); $this->assertFalse($service->validateType('not_registered_widget')); return $service; }
/** * Tests register, exists and unregisrer */ public function testCanRegisterType() { $service = new \Elgg\WidgetsService(array($this, 'elgg_set_config')); $this->assertFalse($service->validateType('widget_type')); $this->assertFalse($service->validateType('not_registered_widget')); $this->assertTrue($service->registerType('widget_type', 'Widget name1', 'Widget description1')); $this->assertTrue($service->registerType('widget_type_con', 'Widget name2', 'Widget description2', array('dashboard', 'profile'))); $this->assertTrue($service->registerType('widget_type_mul', 'Widget name3', 'Widget description3', array('all'), true)); $this->assertTrue($service->registerType('widget_type_con_mul', 'Widget name4', 'Widget description4', array('dashboard', 'settings'), true)); //overwrite $this->assertTrue($service->registerType('widget_type_con_mul', 'Widget name5', 'Widget description5', array('dashboard', 'settings'), true)); $this->assertTrue($service->validateType('widget_type')); $this->assertTrue($service->validateType('widget_type_con')); $this->assertTrue($service->validateType('widget_type_mul')); $this->assertTrue($service->validateType('widget_type_con_mul')); $this->assertFalse($service->validateType('not_registered_widget')); return $service; }