2020-05-15 17:19:03 +00:00
|
|
|
<?php
|
|
|
|
|
2022-04-08 00:38:27 +00:00
|
|
|
use MediaWiki\Extension\Notifications\Push\Subscription;
|
2020-05-15 17:19:03 +00:00
|
|
|
use Wikimedia\Timestamp\ConvertibleTimestamp;
|
|
|
|
|
2022-04-08 00:38:27 +00:00
|
|
|
/** @covers \MediaWiki\Extension\Notifications\Push\Subscription */
|
2020-05-15 17:19:03 +00:00
|
|
|
class SubscriptionTest extends MediaWikiUnitTestCase {
|
|
|
|
|
|
|
|
public function testNewFromRow(): void {
|
2022-09-29 13:41:35 +00:00
|
|
|
$row = (object)[
|
|
|
|
'eps_token' => 'AABC123',
|
|
|
|
'epp_name' => 'fcm',
|
|
|
|
'eps_data' => null,
|
|
|
|
'ept_text' => null,
|
|
|
|
'eps_updated' => '2020-01-01 10:10:10',
|
|
|
|
];
|
2020-05-15 17:19:03 +00:00
|
|
|
|
|
|
|
$subscription = Subscription::newFromRow( $row );
|
2020-08-03 18:27:47 +00:00
|
|
|
$this->assertSame( 'AABC123', $subscription->getToken() );
|
2020-05-15 17:19:03 +00:00
|
|
|
$this->assertSame( 'fcm', $subscription->getProvider() );
|
2020-09-08 13:34:54 +00:00
|
|
|
$this->assertNull( $subscription->getTopic() );
|
2020-05-15 17:19:03 +00:00
|
|
|
$this->assertInstanceOf( ConvertibleTimestamp::class, $subscription->getUpdated() );
|
|
|
|
$this->assertSame( '1577873410', $subscription->getUpdated()->getTimestamp() );
|
|
|
|
}
|
|
|
|
|
2020-08-03 18:27:47 +00:00
|
|
|
public function testNewFromRowWithTopic(): void {
|
2022-09-29 13:41:35 +00:00
|
|
|
$row = (object)[
|
|
|
|
'eps_token' => 'DEF456',
|
|
|
|
'epp_name' => 'apns',
|
|
|
|
'eps_data' => null,
|
|
|
|
'ept_text' => 'test',
|
|
|
|
'eps_updated' => '2020-01-01 10:10:10',
|
|
|
|
];
|
2020-08-03 18:27:47 +00:00
|
|
|
|
|
|
|
$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() );
|
|
|
|
}
|
|
|
|
|
2020-05-15 17:19:03 +00:00
|
|
|
}
|