Guest User

Untitled

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