예제 #1
0
 public function testReadWriteSettings()
 {
     $n = new Notification($this->container);
     $p = new Project($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
     $n->saveSettings(1, array('notifications_enabled' => 1, 'notifications_filter' => NotificationFilter::FILTER_CREATOR, 'notification_types' => array(NotificationType::TYPE_EMAIL => 1), 'notification_projects' => array()));
     $settings = $n->readSettings(1);
     $this->assertNotEmpty($settings);
     $this->assertEquals(1, $settings['notifications_enabled']);
     $this->assertEquals(NotificationFilter::FILTER_CREATOR, $settings['notifications_filter']);
     $this->assertEquals(array(NotificationType::TYPE_EMAIL), $settings['notification_types']);
     $this->assertEmpty($settings['notification_projects']);
     $n->saveSettings(1, array('notifications_enabled' => 0));
     $settings = $n->readSettings(1);
     $this->assertNotEmpty($settings);
     $this->assertEquals(0, $settings['notifications_enabled']);
     $n->saveSettings(1, array('notifications_enabled' => 1, 'notifications_filter' => NotificationFilter::FILTER_ASSIGNEE, 'notification_types' => array(NotificationType::TYPE_WEB => 1, NotificationType::TYPE_EMAIL => 1), 'notification_projects' => array(1 => 1)));
     $settings = $n->readSettings(1);
     $this->assertNotEmpty($settings);
     $this->assertEquals(1, $settings['notifications_enabled']);
     $this->assertEquals(NotificationFilter::FILTER_ASSIGNEE, $settings['notifications_filter']);
     $this->assertEquals(array(NotificationType::TYPE_EMAIL, NotificationType::TYPE_WEB), $settings['notification_types']);
     $this->assertEquals(array(1), $settings['notification_projects']);
 }