Skip to content

Commit f7c4661

Browse files
committed
fix: Made properties in targets private, added tests
1 parent 4709656 commit f7c4661

File tree

6 files changed

+97
-3
lines changed

6 files changed

+97
-3
lines changed

src/Targets/Channel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Channel implements Targetable
99
*
1010
* @var string
1111
*/
12-
protected $channelTag;
12+
private $channelTag;
1313

1414
/**
1515
* Set channel tag.

src/Targets/Device.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Device implements Targetable
99
*
1010
* @var string
1111
*/
12-
protected $deviceId;
12+
private $deviceId;
1313

1414
/**
1515
* Set recipient device id.

src/Targets/Email.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Email implements Targetable
1111
*
1212
* @var string
1313
*/
14-
protected $email;
14+
private $email;
1515

1616
/**
1717
* Set recipient email.

tests/Targets/ChannelTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace NotificationChannels\Pushbullet\Test\Targets;
6+
7+
use NotificationChannels\Pushbullet\Targets\Channel;
8+
use PHPUnit\Framework\TestCase;
9+
10+
/**
11+
* @coversDefaultClass \NotificationChannels\Pushbullet\Targets\Channel
12+
*/
13+
class ChannelTest extends TestCase
14+
{
15+
/**
16+
* @test
17+
*
18+
* @covers ::__construct
19+
* @covers ::getTarget
20+
*/
21+
public function it_is_properly_represented_as_array()
22+
{
23+
$sut = new Channel('channelTag');
24+
25+
$this->assertEquals(['channel_tag' => 'channelTag'], $sut->getTarget());
26+
}
27+
}

tests/Targets/DeviceTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace NotificationChannels\Pushbullet\Test\Targets;
6+
7+
use NotificationChannels\Pushbullet\Targets\Device;
8+
use PHPUnit\Framework\TestCase;
9+
10+
/**
11+
* @coversDefaultClass \NotificationChannels\Pushbullet\Targets\Device
12+
*/
13+
class DeviceTest extends TestCase
14+
{
15+
/**
16+
* @test
17+
*
18+
* @covers ::__construct
19+
* @covers ::getTarget
20+
*/
21+
public function it_is_properly_represented_as_array()
22+
{
23+
$sut = new Device('deviceId');
24+
25+
$this->assertEquals(['device_iden' => 'deviceId'], $sut->getTarget());
26+
}
27+
}

tests/Targets/EmailTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace NotificationChannels\Pushbullet\Test\Targets;
6+
7+
use NotificationChannels\Pushbullet\Exceptions\CouldNotSendNotification;
8+
use NotificationChannels\Pushbullet\Targets\Email;
9+
use PHPUnit\Framework\TestCase;
10+
11+
/**
12+
* @coversDefaultClass \NotificationChannels\Pushbullet\Targets\Email
13+
*/
14+
class EmailTest extends TestCase
15+
{
16+
/**
17+
* @test
18+
*
19+
* @covers ::__construct
20+
* @covers ::getTarget
21+
*/
22+
public function it_is_properly_represented_as_array()
23+
{
24+
$sut = new Email('[email protected]');
25+
26+
$this->assertEquals(['email' => '[email protected]'], $sut->getTarget());
27+
}
28+
29+
/**
30+
* @test
31+
*
32+
* @covers ::__construct
33+
*/
34+
public function invalid_email_is_not_accepted()
35+
{
36+
$this->expectException(CouldNotSendNotification::class);
37+
38+
$sut = new Email('email');
39+
}
40+
}

0 commit comments

Comments
 (0)