once() ->andReturn([0, ['visitor-a', 'visitor-b']]); Redis::shouldReceive('get')->twice()->andReturn(null); Redis::shouldReceive('srem')->once(); Redis::shouldReceive('smembers')->never(); $repository = new OnlineVisitorRepository(app(BotClassifier::class)); $records = $repository->all(); $this->assertSame([], $records); } public function test_source_does_not_call_smembers_on_the_presence_index(): void { $source = file_get_contents(base_path('app/Services/Traffic/OnlineVisitorRepository.php')); $this->assertNotFalse($source); $this->assertStringNotContainsString('smembers', strtolower($source)); $this->assertStringContainsString('sscan', strtolower($source)); } }