| 1 |
<?php |
| 2 |
|
| 3 |
namespace WebPConvert\Tests\Helpers; |
| 4 |
|
| 5 |
use WebPConvert\Helpers\WarningsIntoExceptions; |
| 6 |
use WebPConvert\Exceptions\WarningException; |
| 7 |
|
| 8 |
use PHPUnit\Framework\TestCase; |
| 9 |
|
| 10 |
class WarningsIntoExceptionsTest extends TestCase |
| 11 |
{ |
| 12 |
public function testNothing() |
| 13 |
{ |
| 14 |
$this->assertTrue(true); |
| 15 |
} |
| 16 |
/* |
| 17 |
private static $imgDir = __DIR__ . '/../../images'; |
| 18 |
|
| 19 |
public function testUserWarning() |
| 20 |
{ |
| 21 |
WarningsIntoExceptions::activate(); |
| 22 |
|
| 23 |
$this->expectException(WarningException::class); |
| 24 |
|
| 25 |
// trigger user warning |
| 26 |
trigger_error('warning test', E_USER_WARNING); |
| 27 |
|
| 28 |
WarningsIntoExceptions::deactivate(); |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
public function testWarning() |
| 33 |
{ |
| 34 |
WarningsIntoExceptions::activate(); |
| 35 |
|
| 36 |
$this->expectException(WarningException::class); |
| 37 |
|
| 38 |
// trigger build-in warning (chmod expects exactly two parameters) |
| 39 |
chmod('hth'); |
| 40 |
WarningsIntoExceptions::deactivate(); |
| 41 |
}*/ |
| 42 |
|
| 43 |
|
| 44 |
/* |
| 45 |
To suppress and capture output from exec calls, you need to redirect the stderr to stdout. |
| 46 |
Otherwise it is "echoed to screen" |
| 47 |
|
| 48 |
|
| 49 |
https://stackoverflow.com/questions/1606943/suppressing-output-from-exec-calls-in-php |
| 50 |
public function testWarning2() |
| 51 |
{ |
| 52 |
WarningsIntoExceptions::activate(); |
| 53 |
|
| 54 |
//$this->expectException(WarningException); |
| 55 |
|
| 56 |
//ob_start(); |
| 57 |
exec('hahotehua 2>&1', $output, $returnCode); |
| 58 |
//ob_end_clean(); |
| 59 |
|
| 60 |
WarningsIntoExceptions::deactivate(); |
| 61 |
|
| 62 |
|
| 63 |
}*/ |
| 64 |
} |
| 65 |
|