Skip to content

Commit 7b52263

Browse files
committed
Exception tests
1 parent ed612bc commit 7b52263

2 files changed

Lines changed: 57 additions & 3 deletions

File tree

src/UserAgentParser/Exceptions/UserAgentParserException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88

99
namespace vipnytt\UserAgentParser\Exceptions;
1010

11-
use Exception;
12-
1311
/**
1412
* Class UserAgentParserException
1513
*
1614
* @package vipnytt\UserAgentParser\Exceptions
1715
*/
18-
class UserAgentParserException extends Exception
16+
class UserAgentParserException extends \Exception
1917
{
2018
}

tests/ExceptionTest.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
* vipnytt/UserAgentParser
4+
*
5+
* @link https://github.com/VIPnytt/UserAgentParser
6+
* @license https://github.com/VIPnytt/UserAgentParser/blob/master/LICENSE The MIT License (MIT)
7+
*/
8+
9+
namespace vipnytt\UserAgentParser\Tests;
10+
11+
use PHPUnit\Framework\TestCase;
12+
use vipnytt\UserAgentParser\Exceptions;
13+
14+
/**
15+
* Class ExceptionTest
16+
*
17+
* @package vipnytt\UserAgentParser\Tests
18+
*/
19+
class ExceptionTest extends TestCase
20+
{
21+
/**
22+
* @throws Exceptions\FormatException
23+
*/
24+
public function testFormat()
25+
{
26+
$this->expectException(\InvalidArgumentException::class);
27+
throw new Exceptions\FormatException();
28+
}
29+
30+
/**
31+
* @throws Exceptions\ProductException
32+
*/
33+
public function testProduct()
34+
{
35+
$this->expectException(Exceptions\FormatException::class);
36+
throw new Exceptions\ProductException();
37+
}
38+
39+
/**
40+
* @throws Exceptions\VersionException
41+
*/
42+
public function testVersion()
43+
{
44+
$this->expectException(Exceptions\FormatException::class);
45+
throw new Exceptions\VersionException();
46+
}
47+
48+
/**
49+
* @throws Exceptions\UserAgentParserException
50+
*/
51+
public function testUserAgentParser()
52+
{
53+
$this->expectException(\Exception::class);
54+
throw new Exceptions\UserAgentParserException();
55+
}
56+
}

0 commit comments

Comments
 (0)