RecorderTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Facade\FlareClient\Tests\Glows;
  3. use Facade\FlareClient\Glows\Glow;
  4. use Facade\FlareClient\Glows\Recorder;
  5. use Facade\FlareClient\Tests\TestCase;
  6. class RecorderTest extends TestCase
  7. {
  8. /** @test */
  9. public function it_is_initially_empty()
  10. {
  11. $recorder = new Recorder();
  12. $this->assertCount(0, $recorder->glows());
  13. }
  14. /** @test */
  15. public function it_stores_glows()
  16. {
  17. $recorder = new Recorder();
  18. $glow = new Glow('Some name', 'info', [
  19. 'some' => 'metadata',
  20. ]);
  21. $recorder->record($glow);
  22. $this->assertCount(1, $recorder->glows());
  23. $this->assertSame($glow, $recorder->glows()[0]);
  24. }
  25. /** @test */
  26. public function it_does_not_store_more_than_the_max_defined_number_of_glows()
  27. {
  28. $recorder = new Recorder();
  29. $crumb1 = new Glow('One');
  30. $crumb2 = new Glow('Two');
  31. foreach (range(1, 40) as $i) {
  32. $recorder->record($crumb1);
  33. }
  34. $recorder->record($crumb2);
  35. $recorder->record($crumb1);
  36. $recorder->record($crumb2);
  37. $this->assertCount(Recorder::GLOW_LIMIT, $recorder->glows());
  38. $this->assertSame([
  39. $crumb1, $crumb1, $crumb1, $crumb1, $crumb1, $crumb1, $crumb1, $crumb1, $crumb1, $crumb1,
  40. $crumb1, $crumb1, $crumb1, $crumb1, $crumb1, $crumb1, $crumb1, $crumb1, $crumb1, $crumb1,
  41. $crumb1, $crumb1, $crumb1, $crumb1, $crumb1, $crumb1, $crumb1, $crumb2, $crumb1, $crumb2,
  42. ], $recorder->glows());
  43. }
  44. }