addUser($user2); // Create a SavedExport entity $savedExport = new SavedExport(); // Share the saved export with user1 $savedExport->addShare($user1); // Share the saved export with the group $savedExport->addShare($group); // Assertions $this->assertTrue($savedExport->isSharedWithUser($user1), 'User1 should have access to the saved export.'); $this->assertTrue($savedExport->isSharedWithUser($user2), 'User2 (via group) should have access to the saved export.'); $this->assertFalse($savedExport->isSharedWithUser($user3), 'User3 should not have access to the saved export.'); } }