Skip to content

Commit 50d5401

Browse files
committed
Fix tests
1 parent 12a0887 commit 50d5401

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

src/Events/AbstractEvent.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,5 @@ public function eventName(): string
1313
} else {
1414
abstract class AbstractEvent
1515
{
16-
public function eventName(): string
17-
{
18-
if (method_exists($this, 'getName')) {
19-
return $this->getName();
20-
}
21-
22-
return static::class;
23-
}
2416
}
2517
}

src/Events/UpdateEvent.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ public function __construct(
2222
) {
2323
}
2424

25+
public function eventName(): string
26+
{
27+
return $this->name;
28+
}
29+
2530
public function getName(): string
2631
{
2732
return $this->name;

src/Events/UpdateWasReceived.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Class UpdateWasReceived.
1010
*/
11-
final class UpdateWasReceived extends AbstractEvent implements HasEventName
11+
final class UpdateWasReceived extends AbstractEvent
1212
{
1313
/**
1414
* UpdateWasReceived constructor.
@@ -17,6 +17,11 @@ public function __construct(public Api $telegram, public Update $update)
1717
{
1818
}
1919

20+
public function eventName(): string
21+
{
22+
return self::class;
23+
}
24+
2025
/**
2126
* Backwards compatibility method
2227
*

tests/Integration/Api.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,14 +310,16 @@ function createIncomeWebhookRequestInstance(array $updateData): Request
310310
$update = $api->getWebhookUpdate(true, $incomeWebhookRequest);
311311

312312
expect($update)->toBeEmpty()
313-
->and($listener->numberOfTimeCalled())->toBe(2); // TODO: 2 or 1? Supposed to be one.
313+
->and($listener->numberOfTimeCalled())->toBe(1);
314314
});
315315

316316
it('dispatches 3 events of update event type', function () {
317317
$listener = new ListenerSpy();
318318

319319
$api = api($this->httpClient);
320-
$api->on(UpdateEvent::class, $listener);
320+
$api->on('update', $listener);
321+
$api->on('message', $listener);
322+
$api->on('message.text', $listener);
321323

322324
$incomeWebhookRequest = createIncomeWebhookRequestInstance([
323325
'message' => [ // to help SDK to detect Update of "message" type and send 2nd event (with name "message")

0 commit comments

Comments
 (0)