Skip to content

Commit e577068

Browse files
Merge pull request #4 from perfectmak/master
Implemented Unit Tests
2 parents b32806d + 0715966 commit e577068

File tree

4 files changed

+114
-6
lines changed

4 files changed

+114
-6
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
language: php
22

33
php:
4-
- 5.5
5-
- 5.6
64
- 7.0
75
- hhvm
86

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
"require": {
1414
"php": ">=5.5.9",
1515
"illuminate/support": "5.2.*",
16-
"sinergi/browser-detector":"6.0.*"
16+
"sinergi/browser-detector": "6.0.*"
17+
},
18+
"require-dev": {
19+
"phpunit/phpunit": "5.3.*",
20+
"mockery/mockery": "0.9.*"
1721
},
1822
"autoload": {
1923
"psr-4": {

tests/IdentifyServiceProviderTest.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
namespace Unicodeveloper\Identify\Test;
4+
5+
use Mockery as m;
6+
use PHPUnit_Framework_TestCase;
7+
use Unicodeveloper\Identify\{ Identify, IdentifyServiceProvider };
8+
9+
class IdentifyServiceProviderTest extends PHPUnit_Framework_TestCase
10+
{
11+
12+
/**
13+
* @var MockInterface
14+
*/
15+
protected $mockApp;
16+
17+
/**
18+
* @var IdentifyServiceProvider
19+
*/
20+
protected $provider;
21+
22+
protected function setUp()
23+
{
24+
parent::setUp();
25+
$this->mockApp = m::mock('\Illuminate\Contracts\Foundation\Application');
26+
$this->provider = new IdentifyServiceProvider($this->mockApp);
27+
}
28+
29+
/**
30+
* Test that it registers the correct service name with Identity
31+
*/
32+
public function testRegister()
33+
{
34+
$this->mockApp->shouldReceive('bind')
35+
->once()
36+
->andReturnUsing(function($name, $closure) {
37+
$this->assertEquals('laravel-identify', $name);
38+
$this->assertInstanceOf(Identify::class, $closure());
39+
});
40+
41+
$this->provider->register();
42+
}
43+
44+
/**
45+
* Test that it provides the correct service name
46+
*/
47+
public function testProvides()
48+
{
49+
$expected = ['laravel-identify'];
50+
$actual = $this->provider->provides();
51+
52+
$this->assertEquals($expected, $actual);
53+
}
54+
}

tests/IdentifyTest.php

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,66 @@
33
namespace Unicodeveloper\Identify\Test;
44

55
use PHPUnit_Framework_TestCase;
6+
use Sinergi\BrowserDetector\{ Browser, Device, Language, Os };
7+
use Unicodeveloper\Identify\Identify;
68

79
class IdentifyTest extends PHPUnit_Framework_TestCase
810
{
11+
12+
/**
13+
* Identify Object
14+
* @var Identify
15+
*/
16+
protected $identify;
17+
18+
protected function setUp()
19+
{
20+
parent::setUp();
21+
$this->identify = new Identify();
22+
}
23+
24+
/**
25+
* Test if Identify can be constructed
26+
*
27+
*/
28+
public function testIdentifyCanBeConstructed()
29+
{
30+
$this->assertInstanceOf(Identify::class, $this->identify);
31+
}
32+
33+
/**
34+
* Test if Os is constructed on Identify Object created
35+
*
36+
*/
37+
public function testOSIsInitializedOnIdentifyConstruction()
38+
{
39+
$this->assertInstanceOf(Os::class, $this->identify->os());
40+
}
41+
42+
/**
43+
* Test if Device is constructed on Identify Object created
44+
*
45+
*/
46+
public function testDeviceIsInitializedOnIdentifyConstruction()
47+
{
48+
$this->assertInstanceOf(Device::class, $this->identify->device());
49+
}
50+
51+
/**
52+
* Test if Os is constructed on Identify Object created
53+
*
54+
*/
55+
public function testBrowserIsInitializedOnIdentifyConstruction()
56+
{
57+
$this->assertInstanceOf(Browser::class, $this->identify->browser());
58+
}
59+
960
/**
10-
* Test that true does in fact equal true
61+
* Test if Language is constructed on Identify Object created
62+
*
1163
*/
12-
public function testTrueIsTrue()
64+
public function testLanguageIsInitializedOnIdentifyConstruction()
1365
{
14-
$this->assertTrue(true);
66+
$this->assertInstanceOf(Language::class, $this->identify->lang());
1567
}
1668
}

0 commit comments

Comments
 (0)