Blame view

tests/integration/Forum/CreateDiscussion/LimitNumberOfDiscussionCreatedTest.php 1.18 KB
e77200db5   nologostudio.ru   Initial commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  <?php
  
  namespace FootyRoom\Tests;
  
  class LimitNumberOfDiscussionCreatedTest extends TestCase
  {
      use SetsUpFixtures;
  
      public function testUserShouldNotAllowedToCreateThreePostPerHour()
      {
          $faker = \Faker\Factory::create();
  
          $data = [
              'title' => $faker->sentence(),
              'content' => $faker->paragraph(),
              'category' => 53,
          ];
  
          // Already have 1 post while db setup in listener
  
          $user = factory('FootyRoom\User\User')->make(['user_id' => 1]);
          $response = $this->actingAs($user)->call('POST', '/forum/discussions', $data);
          $this->assertEquals(201, $response->status());
  
          $user = factory('FootyRoom\User\User')->make(['user_id' => 1]);
          $response = $this->actingAs($user)->call('POST', '/forum/discussions', $data);
          $this->assertEquals(201, $response->status());
  
          $user = factory('FootyRoom\User\User')->make(['user_id' => 1]);
          $response = $this->actingAs($user)->call('POST', '/forum/discussions', $data);
          $this->assertEquals(500, $response->status());
          $this->assertContains('Members can post in forum 3 times per hour.', $response->getContent());
      }
  }