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 {
|
|
|
|
$row = new stdClass();
|
2020-08-03 18:27:47 +00:00
|
|
|
$row->eps_token = 'AABC123';
|
2020-06-02 23:20:06 +00:00
|
|
|
$row->epp_name = 'fcm';
|
2020-08-03 18:27:47 +00:00
|
|
|
$row->eps_data = null;
|
2020-09-08 13:34:54 +00:00
|
|
|
$row->ept_text = null;
|
2020-05-15 17:19:03 +00:00
|
|
|
$row->eps_updated = '2020-01-01 10:10:10';
|
|
|
|
|
|
|
|
$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 {
|
|
|
|
$row = new stdClass();
|
|
|
|
$row->eps_token = 'DEF456';
|
|
|
|
$row->epp_name = 'apns';
|
|
|
|
$row->eps_data = null;
|
2020-09-08 13:34:54 +00:00
|
|
|
$row->ept_text = 'test';
|
2020-08-03 18:27:47 +00:00
|
|
|
$row->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() );
|
|
|
|
}
|
|
|
|
|
2020-05-15 17:19:03 +00:00
|
|
|
}
|