mediawiki-extensions-Echo/tests/phpunit/unit/Push/SubscriptionTest.php
Thiemo Kreuz db79d76d83 Use PHPUnit's shortcuts where it makes sense
Notably: any() is the default anyway. It doesn't really make the
tests more specific or better readable when we repeat it all the
time.

Change-Id: I56d201bfce454587b00015b7208f313dd8ed9624
2022-10-26 11:53:57 +02:00

44 lines
1.4 KiB
PHP

<?php
use MediaWiki\Extension\Notifications\Push\Subscription;
use Wikimedia\Timestamp\ConvertibleTimestamp;
/** @covers \MediaWiki\Extension\Notifications\Push\Subscription */
class SubscriptionTest extends MediaWikiUnitTestCase {
public function testNewFromRow(): void {
$row = (object)[
'eps_token' => 'AABC123',
'epp_name' => 'fcm',
'eps_data' => null,
'ept_text' => null,
'eps_updated' => '2020-01-01 10:10:10',
];
$subscription = Subscription::newFromRow( $row );
$this->assertSame( 'AABC123', $subscription->getToken() );
$this->assertSame( 'fcm', $subscription->getProvider() );
$this->assertNull( $subscription->getTopic() );
$this->assertInstanceOf( ConvertibleTimestamp::class, $subscription->getUpdated() );
$this->assertSame( '1577873410', $subscription->getUpdated()->getTimestamp() );
}
public function testNewFromRowWithTopic(): void {
$row = (object)[
'eps_token' => 'DEF456',
'epp_name' => 'apns',
'eps_data' => null,
'ept_text' => 'test',
'eps_updated' => '2020-01-01 10:10:10',
];
$subscription = Subscription::newFromRow( $row );
$this->assertSame( 'DEF456', $subscription->getToken() );
$this->assertSame( 'apns', $subscription->getProvider() );
$this->assertSame( 'test', $subscription->getTopic() );
$this->assertInstanceOf( ConvertibleTimestamp::class, $subscription->getUpdated() );
$this->assertSame( '1577873410', $subscription->getUpdated()->getTimestamp() );
}
}