RecordPlatformDataServiceTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Tests\Unit;
  3. use App\Services\RecordPlatformData;
  4. use ReflectionClass;
  5. use Tests\TestCase;
  6. class RecordPlatformDataServiceTest extends TestCase
  7. {
  8. public function testStatisticsQueriesUseNolockTableExpressions()
  9. {
  10. $source = $this->getServiceSource();
  11. $this->assertContains(
  12. '->table($this->withNoLock(TableName::QPAccountsDB() . \'AccountsInfo as ai\'))',
  13. $source
  14. );
  15. $this->assertContains(
  16. '->table($this->withNoLock(TableName::QPRecordDB() . \'RecordUserLogin as rul\'))',
  17. $source
  18. );
  19. $this->assertContains(
  20. '->table($this->withNoLock(TableName::QPRecordDB() . \'RecordUserDataStatisticsNew as record\'))',
  21. $source
  22. );
  23. $this->assertContains(
  24. '->from($this->withNoLock(TableName::QPRecordDB() . \'RecordUserGamePlay as rl\'))',
  25. $source
  26. );
  27. $this->assertContains(
  28. '->from($this->withNoLock(TableName::QPRecordDB() . \'RecordUserLogin as rl\'))',
  29. $source
  30. );
  31. $this->assertContains(
  32. '->join($this->withNoLock(TableName::QPAccountsDB() . \'AccountsInfo as ai\')',
  33. $source
  34. );
  35. $this->assertNotContains(
  36. "->join(TableName::QPAccountsDB().'AccountsInfo as ai'",
  37. $source
  38. );
  39. }
  40. private function getServiceSource()
  41. {
  42. $reflection = new ReflectionClass(RecordPlatformData::class);
  43. return file_get_contents($reflection->getFileName());
  44. }
  45. }