client = $this->createMock(Client::class); $this->instance = new Ntfy($this->client); } /** * @SuppressWarnings(PHPMD.StaticAccess) */ public function testFactory(): void { $config = ['domain' => 'https://test.com', 'topic' => 'something']; $instance = Ntfy::factory($config); $this->assertInstanceOf(Ntfy::class, $instance); } public function testSend(): void { $this->client->expects($this->once())->method('send')->with($this->isInstanceOf(Message::class)); $this->instance->send('title', 'text'); } /** @return array> */ public static function sendBadParameterProvider(): array { return [ ['', ''], ['', 'text'], ['title', ''], [str_repeat("t", 256),'text'], ['title',str_repeat("t", 4096)], ]; } #[DataProvider('sendBadParameterProvider')] public function testSendInvalidParameters(string $title, string $message): void { $this->expectException(\InvalidArgumentException::class); $this->instance->send($title, $message); } public function testSetTopic(): void { $topic = "abcdefg"; $this->instance->setTopic($topic); $this->assertEquals($topic, $this->instance->getTopic()); } /** @return array> */ public static function topicBadParameterProvider(): array { return [ [''], [str_repeat("t", 256)], [str_repeat("t", 4096)], ]; } #[DataProvider('topicBadParameterProvider')] public function testSetTopicInvalidParameters(string $topic): void { $this->expectException(\InvalidArgumentException::class); $this->instance->setTopic($topic); } }