MCPcopy Create free account
hub / github.com/Rello/analytics / DatasetServiceTest

Class DatasetServiceTest

tests/Service/DatasetServiceTest.php:27–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25use Psr\Log\LoggerInterface;
26
27class DatasetServiceTest extends TestCase {
28 protected function tearDown(): void {
29 $this->setContextChatAvailable(null);
30 if (class_exists('\OC')) {
31 \OC::$server = null;
32 }
33 parent::tearDown();
34 }
35
36 public function testProviderKeepsDatasetUpdateSuccessfulWhenContextChatFails(): void {
37 if (!class_exists('\OC')) {
38 eval('class OC { public static $server; }');
39 }
40
41 $contextChatManager = new class() {
42 public function submitContent(int $datasetId): void {
43 throw new \InvalidArgumentException('Entity which should be updated has no id');
44 }
45 };
46
47 \OC::$server = new class($contextChatManager) {
48 private $contextChatManager;
49
50 public function __construct($contextChatManager) {
51 $this->contextChatManager = $contextChatManager;
52 }
53
54 public function query(string $class) {
55 return $this->contextChatManager;
56 }
57 };
58
59 $logger = $this->createMock(LoggerInterface::class);
60 $logger->expects($this->once())
61 ->method('warning')
62 ->with(
63 'Analytics context chat indexing failed',
64 $this->callback(function (array $context): bool {
65 $this->assertSame(11, $context['datasetId']);
66 $this->assertInstanceOf(\InvalidArgumentException::class, $context['exception']);
67 return true;
68 })
69 );
70
71 $this->setContextChatAvailable(true);
72
73 $service = $this->createService($logger);
74
75 $this->assertTrue($service->provider(11));
76 }
77
78 public function testProviderAllSubmitsEveryIndexedDataset(): void {
79 if (!class_exists('\OC')) {
80 eval('class OC { public static $server; }');
81 }
82
83 $contextChatManager = new class() {
84 public array $submitted = [];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected