Skip to content

Commit

Permalink
Merge pull request #4 from pomaxa/travis
Browse files Browse the repository at this point in the history
travis integration, fixes in tests
  • Loading branch information
Bogdan authored Jul 21, 2017
2 parents fb2a54b + 9599eb4 commit 842753c
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: php
before_script: composer install
php:
- '7.0'
- '7.1'
- nightly
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<phpunit bootstrap="vendor/autoload.php">
<phpunit bootstrap="tests/bootstrap.php">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
Expand Down
21 changes: 9 additions & 12 deletions src/Environment.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
<?php
/**
* Created by PhpStorm.
* User: bogdans
* Date: 17.4.3
* Time: 22:23
*/

namespace MessageQueue;


use Exception\FileCreateError;
use MessageQueue\Exception\FileCreateError;
use Symfony\Component\OptionsResolver\OptionsResolver;

class Environment
Expand Down Expand Up @@ -69,19 +62,23 @@ public function create()
{
$queueDir = $this->queueDir();
if (!@mkdir($queueDir, 0775, true) && !is_dir($queueDir)) {
throw new FileCreateError(error_get_last());
$error = error_get_last();
throw new FileCreateError( " {$error['message']}\n {$error['file']}:{$error['line']}", (int)$error['type']);
}
$readFile = $this->readFile();
if (!is_file($readFile) && !@touch($readFile)) {
throw new FileCreateError(error_get_last());
$error = error_get_last();
throw new FileCreateError( " {$error['message']}\n {$error['file']}:{$error['line']}", (int)$error['type']);
}
$readPointerFile = $this->rotateFile();
if (!is_file($readPointerFile) && !@touch($readPointerFile)) {
throw new FileCreateError(error_get_last());
$error = error_get_last();
throw new FileCreateError( " {$error['message']}\n {$error['file']}:{$error['line']}", (int)$error['type']);
}
$writeFile = $this->writeFile();
if (!is_file($writeFile) && !@touch($writeFile)) {
throw new FileCreateError(error_get_last());
$error = error_get_last();
throw new FileCreateError( " {$error['message']}\n {$error['file']}:{$error['line']}", (int)$error['type']);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FileAccessError.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Exception;
namespace MessageQueue\Exception;


class FileAccessError extends \RuntimeException
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FileCreateError.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Exception;
namespace MessageQueue\Exception;


class FileCreateError extends \RuntimeException
Expand Down
4 changes: 2 additions & 2 deletions tests/EnvironmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function testEnvironmentValidationSuccess()
}

/**
* @expectedException \ErrorException
* @expectedException \MessageQueue\Exception\FileCreateError
*/
public function testEnvironmentValidationCompleteFailure()
{
Expand All @@ -80,7 +80,7 @@ public function testEnvironmentValidationCompleteFailure()
}

/**
* @expectedException \ErrorException
* @expectedException \MessageQueue\Exception\FileCreateError
*/
public function testEnvironmentValidationPartialFailure()
{
Expand Down
11 changes: 11 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
/**
* Created by PhpStorm.
* User: rsvecs
* Date: 21/07/2017
* Time: 23:12
*/

require_once __DIR__.'/../vendor/autoload.php';

putenv('PHP_MSTACK_VAR_DIR='.sys_get_temp_dir());

0 comments on commit 842753c

Please sign in to comment.