mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-18 19:01:28 +00:00
c76761eff3
Bug: T305667 Change-Id: I5a7846a0fc383bddbf6511d6ba73c8be7d7760c7
42 lines
1.5 KiB
PHP
42 lines
1.5 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 = new stdClass();
|
|
$row->eps_token = 'AABC123';
|
|
$row->epp_name = 'fcm';
|
|
$row->eps_data = null;
|
|
$row->ept_text = null;
|
|
$row->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 = new stdClass();
|
|
$row->eps_token = 'DEF456';
|
|
$row->epp_name = 'apns';
|
|
$row->eps_data = null;
|
|
$row->ept_text = 'test';
|
|
$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() );
|
|
}
|
|
|
|
}
|