Exemplo n.º 1
0
 public function testReadWriteSettings()
 {
     $n = new UserNotification($this->container);
     $p = new Project($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
     $n->saveSettings(1, array('notifications_enabled' => 1, 'notifications_filter' => UserNotificationFilter::FILTER_CREATOR, 'notification_types' => array('email' => 1), 'notification_projects' => array()));
     $this->container['userNotificationType']->expects($this->at(0))->method('getSelectedTypes')->will($this->returnValue(array('email')));
     $this->container['userNotificationType']->expects($this->at(1))->method('getSelectedTypes')->will($this->returnValue(array('email')));
     $this->container['userNotificationType']->expects($this->at(2))->method('getSelectedTypes')->with($this->equalTo(1))->will($this->returnValue(array('email', 'web')));
     $settings = $n->readSettings(1);
     $this->assertNotEmpty($settings);
     $this->assertEquals(1, $settings['notifications_enabled']);
     $this->assertEquals(UserNotificationFilter::FILTER_CREATOR, $settings['notifications_filter']);
     $this->assertEquals(array('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' => UserNotificationFilter::FILTER_ASSIGNEE, 'notification_types' => array('web' => 1, 'email' => 1), 'notification_projects' => array(1 => 1)));
     $settings = $n->readSettings(1);
     $this->assertNotEmpty($settings);
     $this->assertEquals(1, $settings['notifications_enabled']);
     $this->assertEquals(UserNotificationFilter::FILTER_ASSIGNEE, $settings['notifications_filter']);
     $this->assertEquals(array('email', 'web'), $settings['notification_types']);
     $this->assertEquals(array(1), $settings['notification_projects']);
 }
 public function testReadWriteSettings()
 {
     $n = new UserNotification($this->container);
     $p = new Project($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
     $n->saveSettings(1, array('notifications_enabled' => 1, 'notifications_filter' => UserNotificationFilter::FILTER_CREATOR, 'notification_types' => array('email' => 1), 'notification_projects' => array()));
     $settings = $n->readSettings(1);
     $this->assertNotEmpty($settings);
     $this->assertEquals(1, $settings['notifications_enabled']);
     $this->assertEquals(UserNotificationFilter::FILTER_CREATOR, $settings['notifications_filter']);
     $this->assertEquals(array('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' => UserNotificationFilter::FILTER_ASSIGNEE, 'notification_types' => array('web' => 1, 'email' => 1), 'notification_projects' => array(1 => 1)));
     $settings = $n->readSettings(1);
     $this->assertNotEmpty($settings);
     $this->assertEquals(1, $settings['notifications_enabled']);
     $this->assertEquals(UserNotificationFilter::FILTER_ASSIGNEE, $settings['notifications_filter']);
     $this->assertEquals(array('email', 'web'), $settings['notification_types']);
     $this->assertEquals(array(1), $settings['notification_projects']);
 }