Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Tests\Feature\Analysis;
  4.  
  5. use App\Post;
  6. use Illuminate\Database\Connection;
  7.  
  8. use Illuminate\Database\DatabaseManager;
  9. use Illuminate\Database\Eloquent\Collection;
  10. use Tests\TestCase;
  11. use Illuminate\Foundation\Testing\WithoutMiddleware;
  12. use Illuminate\Foundation\Testing\DatabaseMigrations;
  13. use Illuminate\Foundation\Testing\DatabaseTransactions;
  14. use Mockery as m;
  15.  
  16. class CountByCategoriesAndPublishedTest extends TestCase
  17. {
  18. public function tearDown()
  19. {
  20. m::close();
  21. parent::tearDown();
  22. }
  23. /**
  24. * @test
  25. * @group analysis
  26. */
  27. public function it_should_get_10_counts()
  28. {
  29. $expected = 10;
  30.  
  31. $connection = m::mock(DatabaseManager::class)->shouldAllowMockingProtectedMethods();
  32. $this->app->instance(DatabaseManager::class, $connection);
  33.  
  34. $connection->shouldReceive('connection')->once()->shouldReceive('makeConnection')->andReturn(true);
  35.  
  36. $instance = m::mock(Post::class);
  37. $this->app->instance(Post::class, $instance);
  38. $instance->shouldReceive('whereIn')->once()
  39. ->shouldReceive('whereBetween')->once()
  40. ->shouldReceive('count')->andReturn(10);
  41.  
  42. $response = $this->get(route('analysis.categories.published', [
  43. '1,2,3',
  44. '2017-06-23'
  45. ]));
  46.  
  47. // I got error.
  48. dd($response->getContent());
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement