Skip to content

Commit 33fc3e5

Browse files
committed
add unit test
1 parent 03bd85f commit 33fc3e5

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

.travis.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
language: php
2+
3+
branches:
4+
- master
5+
6+
php:
7+
- '5.5'
8+
- '7.0'
9+
- '7.1'
10+
11+
script:
12+
- phpunit
13+
14+
cache:
15+
directories:
16+
- $HOME/.composer/cache

src/WorkerProcess.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ public function run()
5353
try {
5454
$result = $executor->execute($job);
5555
} catch (\Exception $e) {
56-
$message = sprintf('tube(%s, #%d): execute job #%d exception, `%s`', $this->tubeName, $process->pid, $job['id'], $e->getMessage());
56+
$message = sprintf('tube(%s, #%d): execute job #%d exception, `%s`', $this->tubeName, $process->pid, $job['id'], $e->getTraceAsString());
5757
$logger->error($message, $job);
5858
throw $e;
5959
} catch (\Throwable $e) {
60-
$message = sprintf('tube(%s, #%d): execute job #%d error, `%s`', $this->tubeName, $process->pid, $job['id'], $e->getMessage());
60+
$message = sprintf('tube(%s, #%d): execute job #%d error, `%s`', $this->tubeName, $process->pid, $job['id'], $e->getTraceAsString());
6161
$logger->error($message, $job);
6262
throw $e;
6363
}

tests/ThrowableTest.php

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use PHPUnit\Framework\TestCase;
4+
use Codeages\Plumber\ForwardWorker;
5+
use Pimple\Container;
6+
use Monolog\Logger;
7+
use Monolog\Handler\TestHandler;
8+
use Codeages\Plumber\IWorker;
9+
10+
11+
class WorkerProcessTest extends TestCase
12+
{
13+
/**
14+
* Can this test run in php 5 ?
15+
*/
16+
public function test_ThrowableException()
17+
{
18+
try {
19+
throw \RuntimeException("some exception");
20+
} catch (\Exception $e) {
21+
22+
} catch (\Throwable $e) {
23+
24+
}
25+
26+
$this->assertTrue(true);
27+
}
28+
}

0 commit comments

Comments
 (0)