Skip to content

Commit 74a6eff

Browse files
Fix - Avoid running duplicate unit test on each testcase
1 parent fa9d962 commit 74a6eff

File tree

3 files changed

+42
-62
lines changed

3 files changed

+42
-62
lines changed

tests/Adapters/KapAdapterTest.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,6 @@ protected function getEnvironmentSetUp($app)
1919
]);
2020
}
2121

22-
/**
23-
* {@inheritdoc}
24-
*/
25-
public function setUp()
26-
{
27-
parent::setUp();
28-
$this->manager = Sms::app(Sms::KapAdapter());
29-
}
30-
3122
/**
3223
* @test
3324
* @expectedException Linkstreet\LaravelSms\Exceptions\AdapterException
@@ -90,8 +81,8 @@ public function sendSms()
9081
$stub->setClient(new \GuzzleHttp\Client(['handler' => \GuzzleHttp\HandlerStack::create($mock)]));
9182

9283
$response = Sms::app($stub)
93-
->to($this->devices)
94-
->send($this->message);
84+
->to(Sms::DeviceCollection([Sms::Device('+910000000001'), Sms::Device('00000')]))
85+
->send(Sms::Message('Hello world'));
9586

9687
$this->assertEquals(200, $response->getStatusCode());
9788
$this->assertTrue((bool) $response->getSuccessCount());

tests/CoreTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace Linkstreet\LaravelSms\Tests;
4+
5+
use Sms;
6+
7+
class CoreTest extends TestCase
8+
{
9+
/**
10+
* Test the device model
11+
*/
12+
public function testDevice()
13+
{
14+
$device = Sms::Device('+910000000000');
15+
$this->assertSame('+910000000001', $device->setNumber('+910000000001')->getNumber());
16+
}
17+
18+
/**
19+
* Test the device collection & device
20+
*/
21+
public function testDeviceCollection()
22+
{
23+
$number1 = '+910000000001';
24+
$number2 = '+910000000002';
25+
$devices = Sms::DeviceCollection([Sms::Device($number1), Sms::Device($number2)]);
26+
27+
$this->assertSame(2, $devices->count());
28+
$this->assertSame($number1, $devices->get($number1)->getNumber());
29+
$this->assertSame($number2, $devices->get($number2)->getNumber());
30+
}
31+
32+
/**
33+
* Test the message model
34+
*/
35+
public function testMessage()
36+
{
37+
$message = Sms::Message('Hello world');
38+
$this->assertSame('Hello world!', $message->setMessage('Hello world!')->getMessage());
39+
}
40+
}

tests/TestCase.php

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,8 @@
22

33
namespace Linkstreet\LaravelSms\Tests;
44

5-
use Sms;
6-
75
abstract class TestCase extends \Orchestra\Testbench\TestCase
86
{
9-
public $device;
10-
11-
public $devices;
12-
13-
public $message;
14-
157
/**
168
* {@inheritdoc}
179
*/
@@ -29,47 +21,4 @@ protected function getPackageAliases($app)
2921
'Sms' => 'Linkstreet\LaravelSms\Facades\Sms'
3022
];
3123
}
32-
33-
/**
34-
* {@inheritdoc}
35-
*/
36-
public function setUp()
37-
{
38-
parent::setUp();
39-
$this->device = Sms::Device('+910000000000');
40-
$this->testDevice();
41-
$this->devices = Sms::DeviceCollection([$this->device, Sms::Device('00000')]);
42-
$this->testDeviceCollection();
43-
$this->message = Sms::Message('Hello world');
44-
$this->testMessage();
45-
}
46-
47-
/**
48-
* Test the device model
49-
*/
50-
public function testDevice()
51-
{
52-
$this->assertSame('+910000000001', $this->device->setNumber('+910000000001')->getNumber());
53-
}
54-
55-
/**
56-
* Test the device collection & device
57-
*/
58-
public function testDeviceCollection()
59-
{
60-
$count = 0;
61-
foreach ($this->devices as $device) {
62-
$count++;
63-
}
64-
$this->assertSame($count, $this->devices->count());
65-
$this->assertSame($this->device, $this->devices->get('+910000000001'));
66-
}
67-
68-
/**
69-
* Test the message model
70-
*/
71-
public function testMessage()
72-
{
73-
$this->assertSame('Hello world!', $this->message->setMessage('Hello world!')->getMessage());
74-
}
7524
}

0 commit comments

Comments
 (0)