|
| 1 | +<?php |
| 2 | + |
| 3 | +use Minishlink\WebPush\Subscription; |
| 4 | + |
| 5 | +class SubscriptionTest extends PHPUnit\Framework\TestCase |
| 6 | +{ |
| 7 | + |
| 8 | + public function testCreateMinimal() |
| 9 | + { |
| 10 | + $subscriptionArray = array( |
| 11 | + "endpoint" => "http://toto.com" |
| 12 | + ); |
| 13 | + $subscription = Subscription::create($subscriptionArray); |
| 14 | + $this->assertEquals("http://toto.com", $subscription->getEndpoint()); |
| 15 | + $this->assertEquals(null, $subscription->getPublicKey()); |
| 16 | + $this->assertEquals(null, $subscription->getAuthToken()); |
| 17 | + $this->assertEquals(null, $subscription->getContentEncoding()); |
| 18 | + } |
| 19 | + |
| 20 | + public function testConstructMinimal() |
| 21 | + { |
| 22 | + $subscription = new Subscription("http://toto.com"); |
| 23 | + $this->assertEquals("http://toto.com", $subscription->getEndpoint()); |
| 24 | + $this->assertEquals(null, $subscription->getPublicKey()); |
| 25 | + $this->assertEquals(null, $subscription->getAuthToken()); |
| 26 | + $this->assertEquals(null, $subscription->getContentEncoding()); |
| 27 | + } |
| 28 | + |
| 29 | + public function testCreatePartial() |
| 30 | + { |
| 31 | + $subscriptionArray = array( |
| 32 | + "endpoint" => "http://toto.com", |
| 33 | + "publicKey" => "publicKey", |
| 34 | + "authToken" => "authToken", |
| 35 | + ); |
| 36 | + $subscription = Subscription::create($subscriptionArray); |
| 37 | + $this->assertEquals("http://toto.com", $subscription->getEndpoint()); |
| 38 | + $this->assertEquals("publicKey", $subscription->getPublicKey()); |
| 39 | + $this->assertEquals("authToken", $subscription->getAuthToken()); |
| 40 | + $this->assertEquals("aesgcm", $subscription->getContentEncoding()); |
| 41 | + } |
| 42 | + |
| 43 | + public function testConstructPartial() |
| 44 | + { |
| 45 | + $subscription = new Subscription("http://toto.com", "publicKey", "authToken"); |
| 46 | + $this->assertEquals("http://toto.com", $subscription->getEndpoint()); |
| 47 | + $this->assertEquals("publicKey", $subscription->getPublicKey()); |
| 48 | + $this->assertEquals("authToken", $subscription->getAuthToken()); |
| 49 | + $this->assertEquals("aesgcm", $subscription->getContentEncoding()); |
| 50 | + } |
| 51 | + |
| 52 | + public function testCreateFull() |
| 53 | + { |
| 54 | + $subscriptionArray = array( |
| 55 | + "endpoint" => "http://toto.com", |
| 56 | + "publicKey" => "publicKey", |
| 57 | + "authToken" => "authToken", |
| 58 | + "contentEncoding" => "aes128gcm", |
| 59 | + ); |
| 60 | + $subscription = Subscription::create($subscriptionArray); |
| 61 | + $this->assertEquals("http://toto.com", $subscription->getEndpoint()); |
| 62 | + $this->assertEquals("publicKey", $subscription->getPublicKey()); |
| 63 | + $this->assertEquals("authToken", $subscription->getAuthToken()); |
| 64 | + $this->assertEquals("aes128gcm", $subscription->getContentEncoding()); |
| 65 | + } |
| 66 | + |
| 67 | + public function testConstructFull() |
| 68 | + { |
| 69 | + $subscription = new Subscription("http://toto.com", "publicKey", "authToken", "aes128gcm"); |
| 70 | + $this->assertEquals("http://toto.com", $subscription->getEndpoint()); |
| 71 | + $this->assertEquals("publicKey", $subscription->getPublicKey()); |
| 72 | + $this->assertEquals("authToken", $subscription->getAuthToken()); |
| 73 | + $this->assertEquals("aes128gcm", $subscription->getContentEncoding()); |
| 74 | + } |
| 75 | +} |
0 commit comments