Advertisement
Guest User

Untitled

a guest
Jan 15th, 2017
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. //
  5. // Oussama Elgoumri
  6. // ktsnepyg9igfz1@gmail.com
  7. //
  8. // Wed Jan 11 13:05:57 WET 2017
  9. //
  10.  
  11.  
  12. namespace App\Api;
  13.  
  14.  
  15. use PHPUnit\Framework\TestCase;
  16.  
  17.  
  18. class XTreamTest extends TestCase
  19. {
  20. public function setUp()
  21. {
  22. $this->faker = \Faker\Factory::create();
  23. }
  24.  
  25. /**
  26. * @test
  27. */
  28. public function createNewLine()
  29. {
  30. $f = $this->faker;
  31. $username = str_random(10);
  32. $password = str_random(10);
  33. $max_connections = mt_rand(1, 10);
  34. $is_restreamer = $f->boolean;
  35. $exp_date = strtotime('+' . mt_rand(1, 12) . ' month');
  36. $bouquet = json_encode([ 1, 2, 3 ]);
  37.  
  38. $data = [
  39. 'username' => $username,
  40. 'password' => $password,
  41. 'max_connections' => $max_connections,
  42. 'is_restreamer' => $is_restreamer,
  43. 'exp_date' => $exp_date,
  44. 'bouquet' => $bouquet,
  45. ];
  46.  
  47. $results = XTream__createNewLine($data);
  48. $this->assertTrue($results['result']);
  49. $this->assertEquals($results['username'], $username);
  50. $this->assertEquals($results['password'], $password);
  51.  
  52. $info = $this->viewLineInfo($results['username'], $results['password']);
  53. $this->assertTrue($info['result']);
  54. $this->assertEquals($info['user_info']['username'], $username);
  55. $this->assertEquals($info['user_info']['password'], $password);
  56. $this->assertEquals($info['user_info']['exp_date'], $exp_date);
  57. $this->assertEquals(json_encode($info['user_info']['bouquet']), $bouquet);
  58. $this->assertEquals($info['user_info']['max_connections'], $max_connections);
  59. $this->assertEquals((bool) $info['user_info']['is_restreamer'], (bool) $is_restreamer);
  60. }
  61.  
  62. /**
  63. * @test
  64. */
  65. public function editLine()
  66. {
  67. $data = XTream__createNewLine([]);
  68.  
  69. $results = XTream__editLine(
  70. $data['username'],
  71. $data['password'],
  72. [
  73. 'password' => 'pass',
  74. ]
  75. );
  76.  
  77. $this->assertTrue($results['result']);
  78. }
  79.  
  80. private function viewLineInfo($username, $password)
  81. {
  82. return XTream__viewLineInfo($username, $password);
  83. }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement