Skip to content

Commit 57a4887

Browse files
committed
This package will be developed for PHP 7.x only.
1 parent 3416272 commit 57a4887

9 files changed

+75
-43
lines changed

.travis.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
language: php
22
php:
3-
- '5.4'
4-
- '5.5'
5-
- '5.6'
63
- '7.0'
7-
- hhvm
4+
- '7.1'
85
- nightly
96

107
install:

build.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project name="php-affirm" default="build" basedir=".">
2+
<project name="php-exception" default="build" basedir=".">
33
<target name="build">
44
</target>
55

6+
<!-- Run composer update -->
7+
<target name="update">
8+
<exec command="composer update" checkreturn="true" passthru="true"/>
9+
</target>
10+
611
<!-- Runs ApiGen -->
712
<target name="apigen">
813
<exec command="apigen generate --todo --tree --source src --destination doc" passthru="true" checkreturn="true"/>

composer.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@
22
"name": "setbased/exception",
33
"description": "Exceptions with format string",
44
"keywords": [
5-
"Exception", "Format"
5+
"Exception",
6+
"Format"
67
],
78
"type": "library",
89
"license": "MIT",
910
"require": {
10-
"php": ">=5.4.0"
11+
"php": ">=7.0.0"
1112
},
1213
"require-dev": {
13-
"phing/phing": "2.*",
14-
"phpunit/phpunit": ">=4.0 <6.0"
14+
"phing/phing": "^2.0.0",
15+
"phpunit/phpunit": "^6.0.0"
1516
},
1617
"autoload": {
1718
"psr-4": {
1819
"SetBased\\Exception\\": "src/"
1920
}
2021
},
22+
"autoload-dev": {
23+
"psr-4": {
24+
"SetBased\\Exception\\Test\\": "test/"
25+
}
26+
},
2127
"config": {
2228
"bin-dir": "bin"
2329
}

test/ErrorExceptionTest.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
<?php
22
//----------------------------------------------------------------------------------------------------------------------
3+
namespace SetBased\Exception\Test;
4+
5+
use PHPUnit\Framework\TestCase;
36
use SetBased\Exception\ErrorException;
47

5-
//----------------------------------------------------------------------------------------------------------------------
6-
class ErrorExceptionTest extends PHPUnit_Framework_TestCase
8+
/**
9+
* Test cases for class ErrorException.
10+
*/
11+
class ErrorExceptionTest extends TestCase
712
{
813
//--------------------------------------------------------------------------------------------------------------------
914
/**
@@ -17,7 +22,7 @@ public function test1()
1722
}
1823
catch (ErrorException $e)
1924
{
20-
$this->assertSame('PHP Warning', $e->getName());
25+
self::assertSame('PHP Warning', $e->getName());
2126
}
2227
}
2328

@@ -33,7 +38,7 @@ public function test2()
3338
}
3439
catch (ErrorException $e)
3540
{
36-
$this->assertSame('Error', $e->getName());
41+
self::assertSame('Error', $e->getName());
3742
}
3843
}
3944

test/FallenExceptionTest.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
<?php
22
//----------------------------------------------------------------------------------------------------------------------
3+
namespace SetBased\Exception\Test;
4+
5+
use PHPUnit\Framework\TestCase;
36
use SetBased\Exception\FallenException;
47

5-
//----------------------------------------------------------------------------------------------------------------------
6-
class FallenExceptionTest extends PHPUnit_Framework_TestCase
8+
/**
9+
* Test cases for class ErrorException.
10+
*/
11+
class FallenExceptionTest extends TestCase
712
{
813
//--------------------------------------------------------------------------------------------------------------------
914
public function testName()
@@ -12,11 +17,11 @@ public function testName()
1217
{
1318
throw new FallenException('foo', 'bar');
1419
}
15-
catch (Exception $e)
20+
catch (\Exception $e)
1621
{
17-
$this->assertContains('foo', $e->getMessage());
18-
$this->assertContains('bar', $e->getMessage());
19-
$this->assertInstanceOf('\RuntimeException', $e);
22+
self::assertContains('foo', $e->getMessage());
23+
self::assertContains('bar', $e->getMessage());
24+
self::assertInstanceOf('\RuntimeException', $e);
2025
}
2126
}
2227

test/FormattedExceptionTestBase.php

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
<?php
22
//----------------------------------------------------------------------------------------------------------------------
3+
namespace SetBased\Exception\Test;
4+
5+
use PHPUnit\Framework\TestCase;
36
use SetBased\Exception\NamedException;
47

5-
//----------------------------------------------------------------------------------------------------------------------
6-
class FormattedExceptionTestBase extends PHPUnit_Framework_TestCase
8+
/**
9+
* Test cases for class FormattedException.
10+
*/
11+
class FormattedExceptionTestBase extends TestCase
712
{
813
//--------------------------------------------------------------------------------------------------------------------
914
static $class;
@@ -27,10 +32,10 @@ public function testName()
2732

2833
throw new self::$class([$num], $format, $num, $location);
2934
}
30-
catch (Exception $e)
35+
catch (\Exception $e)
3136
{
3237
/** @var $e NamedException */
33-
$this->assertSame(self::$name, $e->getName());
38+
self::assertSame(self::$name, $e->getName());
3439
}
3540
}
3641

@@ -49,10 +54,10 @@ public function testCode()
4954

5055
throw new self::$class([$num], $format, $num, $location);
5156
}
52-
catch (Exception $e)
57+
catch (\Exception $e)
5358
{
54-
$this->assertSame('There are 5 monkeys in the tree', $e->getMessage());
55-
$this->assertSame($num, $e->getCode());
59+
self::assertSame('There are 5 monkeys in the tree', $e->getMessage());
60+
self::assertSame($num, $e->getCode());
5661
}
5762
}
5863

@@ -71,9 +76,9 @@ public function testFormatting()
7176

7277
throw new self::$class($format, $num, $location);
7378
}
74-
catch (Exception $e)
79+
catch (\Exception $e)
7580
{
76-
$this->assertSame('There are 5 monkeys in the tree', $e->getMessage());
81+
self::assertSame('There are 5 monkeys in the tree', $e->getMessage());
7782
}
7883
}
7984

@@ -93,10 +98,10 @@ public function testPrevious()
9398

9499
throw new self::$class([$previous], $format, $num, $location);
95100
}
96-
catch (Exception $e)
101+
catch (\Exception $e)
97102
{
98-
$this->assertSame('There are 5 monkeys in the tree', $e->getMessage());
99-
$this->assertSame($previous, $e->getPrevious());
103+
self::assertSame('There are 5 monkeys in the tree', $e->getMessage());
104+
self::assertSame($previous, $e->getPrevious());
100105
}
101106
}
102107

@@ -116,11 +121,11 @@ public function testCodePrevious()
116121

117122
throw new self::$class([$num, $previous], $format, $num, $location);
118123
}
119-
catch (Exception $e)
124+
catch (\Exception $e)
120125
{
121-
$this->assertSame('There are 5 monkeys in the tree', $e->getMessage());
122-
$this->assertSame($previous, $e->getPrevious());
123-
$this->assertSame($num, $e->getCode());
126+
self::assertSame('There are 5 monkeys in the tree', $e->getMessage());
127+
self::assertSame($previous, $e->getPrevious());
128+
self::assertSame($num, $e->getCode());
124129
}
125130
}
126131

@@ -140,11 +145,11 @@ public function testPreviousCode()
140145

141146
throw new self::$class([$previous, $num], $format, $num, $location);
142147
}
143-
catch (Exception $e)
148+
catch (\Exception $e)
144149
{
145-
$this->assertSame('There are 5 monkeys in the tree', $e->getMessage());
146-
$this->assertSame($previous, $e->getPrevious());
147-
$this->assertSame($num, $e->getCode());
150+
self::assertSame('There are 5 monkeys in the tree', $e->getMessage());
151+
self::assertSame($previous, $e->getPrevious());
152+
self::assertSame($num, $e->getCode());
148153
}
149154
}
150155

test/LogicExceptionTest.php renamed to test/LogicFormattedExceptionTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<?php
22
//----------------------------------------------------------------------------------------------------------------------
3-
class LogicFormattedExceptionTest extends \FormattedExceptionTestBase
3+
namespace SetBased\Exception\Test;
4+
5+
/**
6+
* Test case for class LogicException.
7+
*/
8+
class LogicFormattedExceptionTest extends FormattedExceptionTestBase
49
{
510
//--------------------------------------------------------------------------------------------------------------------
611
public function setUp()

test/RuntimeExceptionTest.php renamed to test/RuntimeFormattedExceptionTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
<?php
22
//----------------------------------------------------------------------------------------------------------------------
3-
class RuntimeFormattedExceptionTest extends \FormattedExceptionTestBase
3+
namespace SetBased\Exception\Test;
4+
5+
/**
6+
* Test cases for class RuntimeException.
7+
*/
8+
class RuntimeFormattedExceptionTest extends FormattedExceptionTestBase
49
{
510
//--------------------------------------------------------------------------------------------------------------------
611
public function setUp()
712
{
813
parent::setUp();
914

1015
self::$class = '\SetBased\Exception\RuntimeException';
11-
self::$name = 'Error';
16+
self::$name = 'Error';
1217
}
1318

1419
//--------------------------------------------------------------------------------------------------------------------

test/bootstrap.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33
date_default_timezone_set( 'Europe/Amsterdam' );
44

55
require_once( __DIR__.'/../vendor/autoload.php' );
6-
require_once('FormattedExceptionTestBase.php' );
76

87
//----------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)