PushTest.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace tests;
  3. class PushTest extends Base
  4. {
  5. public function __construct()
  6. {
  7. parent::__construct();
  8. }
  9. public function testUpdateUserNickname()
  10. {
  11. $username = Utils::randomUserName();
  12. $password = Utils::randomPassword();
  13. $this->assertArrayNotHasKey('code', $this->user->create(array('username' => $username, 'password' => $password)));
  14. $this->assertTrue($this->push->updateUserNickname($username, sprintf("nickname-%s", $username)));
  15. $data = $this->user->get($username);
  16. $this->assertArrayHasKey('uuid', $data);
  17. $this->assertEquals('nickname-' . $data['username'], $data['nickname']);
  18. $this->assertTrue($this->user->delete($username));
  19. }
  20. public function testNotificationDisplayStyle()
  21. {
  22. $username = Utils::randomUserName();
  23. $password = Utils::randomPassword();
  24. $this->assertArrayNotHasKey('code', $this->user->create(array('username' => $username, 'password' => $password)));
  25. $this->assertTrue($this->push->setNotificationDisplayStyle($username, 0));
  26. $data = $this->user->get($username);
  27. $this->assertEquals('0', $data['notification_display_style']);
  28. $this->assertTrue($this->push->setNotificationDisplayStyle($username));
  29. $data = $this->user->get($username);
  30. $this->assertEquals('1', $data['notification_display_style']);
  31. $this->assertTrue($this->user->delete($username));
  32. }
  33. public function testOpenCloseNotificationNoDisturbing()
  34. {
  35. $username = Utils::randomUserName();
  36. $password = Utils::randomPassword();
  37. $this->assertArrayNotHasKey('code', $this->user->create(array('username' => $username, 'password' => $password)));
  38. $this->assertTrue($this->push->openNotificationNoDisturbing($username, 10, 19));
  39. $data = $this->user->get($username);
  40. $this->assertTrue($data['notification_no_disturbing']);
  41. $this->assertTrue($this->push->closeNotificationNoDisturbing($username));
  42. $data = $this->user->get($username);
  43. $this->assertFalse($data['notification_no_disturbing']);
  44. $this->assertTrue($this->user->delete($username));
  45. }
  46. }