CourseTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace Tests\Feature;
  3. use Illuminate\Foundation\Testing\RefreshDatabase;
  4. use Illuminate\Foundation\Testing\WithFaker;
  5. use Tests\TestCase;
  6. class CourseTest extends TestCase
  7. {
  8. /**
  9. * A basic feature test example.
  10. *
  11. * @return void
  12. */
  13. private $token = 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJuYmYiOjE2NjgyMzE3MTksImV4cCI6MTY5OTc2NzcxOSwidWlkIjoiYmE1NDYzZjMtNzJkMS00NDEwLTg1OGUtZWFkZDEwODg0NzEzIiwiaWQiOiI0In0.LV4ItC5VCqXpbKIXT1zePcnfi-heCf3Df63w7qbXsT1i5KJtwJJC938CLgANjqwcQFa3lrR5TqvT1kkqD-Mmgg';
  14. public function test_index(){
  15. $response = $this->withHeaders([
  16. 'Authorization' => $this->token,
  17. ])->get('/api/v2/course?view=create');
  18. $response->assertOk();
  19. $response = $this->withHeaders([
  20. 'Authorization' => $this->token,
  21. ])->get('/api/v2/course?view=study');
  22. $response->assertOk();
  23. }
  24. public function test_store()
  25. {
  26. //testing store
  27. $response = $this->withHeaders([
  28. 'Authorization' => $this->token,
  29. ])->json('POST', '/api/v2/course',
  30. [
  31. 'title'=>'course1',
  32. 'studio'=>'visuddhinanda'
  33. ]);
  34. $response->assertOk();
  35. }
  36. public function test_delete(){
  37. //testing delete
  38. $member = Course::where('title','course1')
  39. ->first();
  40. $response = $this->withHeaders([
  41. 'Authorization' => $this->token,
  42. ])->delete('/api/v2/course/'.$member->id);
  43. $response->assertOk();
  44. }
  45. }