Skip to content

Commit 9599eb4

Browse files
committed
+ travis
+ rework bootstrap for tests + fix namespaces; remove stupid debug
1 parent fc26c70 commit 9599eb4

File tree

7 files changed

+31
-17
lines changed

7 files changed

+31
-17
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: php
2+
before_script: composer install
3+
php:
4+
- '7.0'
5+
- '7.1'
6+
- nightly

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<phpunit bootstrap="vendor/autoload.php">
1+
<phpunit bootstrap="tests/bootstrap.php">
22
<testsuites>
33
<testsuite name="default">
44
<directory>tests</directory>

src/Environment.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
<?php
2-
/**
3-
* Created by PhpStorm.
4-
* User: bogdans
5-
* Date: 17.4.3
6-
* Time: 22:23
7-
*/
82

93
namespace MessageQueue;
104

11-
12-
use Exception\FileCreateError;
5+
use MessageQueue\Exception\FileCreateError;
136
use Symfony\Component\OptionsResolver\OptionsResolver;
147

158
class Environment
@@ -69,19 +62,23 @@ public function create()
6962
{
7063
$queueDir = $this->queueDir();
7164
if (!@mkdir($queueDir, 0775, true) && !is_dir($queueDir)) {
72-
throw new FileCreateError(error_get_last());
65+
$error = error_get_last();
66+
throw new FileCreateError( " {$error['message']}\n {$error['file']}:{$error['line']}", (int)$error['type']);
7367
}
7468
$readFile = $this->readFile();
7569
if (!is_file($readFile) && !@touch($readFile)) {
76-
throw new FileCreateError(error_get_last());
70+
$error = error_get_last();
71+
throw new FileCreateError( " {$error['message']}\n {$error['file']}:{$error['line']}", (int)$error['type']);
7772
}
7873
$readPointerFile = $this->rotateFile();
7974
if (!is_file($readPointerFile) && !@touch($readPointerFile)) {
80-
throw new FileCreateError(error_get_last());
75+
$error = error_get_last();
76+
throw new FileCreateError( " {$error['message']}\n {$error['file']}:{$error['line']}", (int)$error['type']);
8177
}
8278
$writeFile = $this->writeFile();
8379
if (!is_file($writeFile) && !@touch($writeFile)) {
84-
throw new FileCreateError(error_get_last());
80+
$error = error_get_last();
81+
throw new FileCreateError( " {$error['message']}\n {$error['file']}:{$error['line']}", (int)$error['type']);
8582
}
8683
}
8784

src/Exception/FileAccessError.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Exception;
3+
namespace MessageQueue\Exception;
44

55

66
class FileAccessError extends \RuntimeException

src/Exception/FileCreateError.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Exception;
3+
namespace MessageQueue\Exception;
44

55

66
class FileCreateError extends \RuntimeException

tests/EnvironmentTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function testEnvironmentValidationSuccess()
6969
}
7070

7171
/**
72-
* @expectedException \ErrorException
72+
* @expectedException \MessageQueue\Exception\FileCreateError
7373
*/
7474
public function testEnvironmentValidationCompleteFailure()
7575
{
@@ -80,7 +80,7 @@ public function testEnvironmentValidationCompleteFailure()
8080
}
8181

8282
/**
83-
* @expectedException \ErrorException
83+
* @expectedException \MessageQueue\Exception\FileCreateError
8484
*/
8585
public function testEnvironmentValidationPartialFailure()
8686
{

tests/bootstrap.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: rsvecs
5+
* Date: 21/07/2017
6+
* Time: 23:12
7+
*/
8+
9+
require_once __DIR__.'/../vendor/autoload.php';
10+
11+
putenv('PHP_MSTACK_VAR_DIR='.sys_get_temp_dir());

0 commit comments

Comments
 (0)