From 3185ee8a9eea0dab43a13b7eae4fb19dcf6cc774 Mon Sep 17 00:00:00 2001 From: geekcom Date: Mon, 15 Apr 2019 13:43:20 -0300 Subject: [PATCH] minor corrections, tests improvement --- src/PHPJasper.php | 16 +++++++++------- tests/PHPJasperTest.php | 16 +++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/PHPJasper.php b/src/PHPJasper.php index 240cbf2..7a935a5 100644 --- a/src/PHPJasper.php +++ b/src/PHPJasper.php @@ -13,6 +13,8 @@ namespace PHPJasper; +use PHPJasper\Exception; + class PHPJasper { @@ -68,7 +70,7 @@ private function checkServer() public function compile(string $input, string $output = '') { if (!is_file($input)) { - throw new \PHPJasper\Exception\InvalidInputFile(); + throw new Exception\InvalidInputFile(); } $this->command = $this->checkServer(); @@ -95,7 +97,7 @@ public function process(string $input, string $output, array $options = []) $options = $this->parseProcessOptions($options); if (!$input) { - throw new \PHPJasper\Exception\InvalidInputFile(); + throw new Exception\InvalidInputFile(); } $this->validateFormat($options['format']); @@ -175,7 +177,7 @@ protected function validateFormat($format) } foreach ($format as $value) { if (!in_array($value, $this->formats)) { - throw new \PHPJasper\Exception\InvalidFormat(); + throw new Exception\InvalidFormat(); } } } @@ -188,7 +190,7 @@ protected function validateFormat($format) public function listParameters(string $input) { if (!is_file($input)) { - throw new \PHPJasper\Exception\InvalidInputFile(); + throw new Exception\InvalidInputFile(); } $this->command = $this->checkServer(); @@ -216,7 +218,7 @@ public function execute($user = false) chdir($this->pathExecutable); exec($this->command, $output, $returnVar); if ($returnVar !== 0) { - throw new \PHPJasper\Exception\ErrorCommandExecutable(); + throw new Exception\ErrorCommandExecutable(); } return $output; @@ -247,10 +249,10 @@ protected function addUserToCommand($user) protected function validateExecute() { if (!$this->command) { - throw new \PHPJasper\Exception\InvalidCommandExecutable(); + throw new Exception\InvalidCommandExecutable(); } if (!is_dir($this->pathExecutable)) { - throw new \PHPJasper\Exception\InvalidResourceDirectory(); + throw new Exception\InvalidResourceDirectory(); } } } diff --git a/tests/PHPJasperTest.php b/tests/PHPJasperTest.php index 3251fe6..b328699 100644 --- a/tests/PHPJasperTest.php +++ b/tests/PHPJasperTest.php @@ -15,15 +15,13 @@ use PHPUnit\Framework\TestCase; use PHPJasper\PHPJasper; +use PHPJasper\Exception; /** * @author Rafael Queiroz */ final class PHPJasperTest extends TestCase { - /** - * @var - */ private $instance; public function setUp() @@ -72,7 +70,7 @@ public function testListParameters() public function testCompileWithWrongInput() { - $this->expectException(\PHPJasper\Exception\InvalidInputFile::class); + $this->expectException(Exception\InvalidInputFile::class); $this->instance->compile(''); } @@ -86,14 +84,14 @@ public function testCompileHelloWorld() public function testExecuteWithoutCompile() { - $this->expectException(\PHPJasper\Exception\InvalidCommandExecutable::class); + $this->expectException(Exception\InvalidCommandExecutable::class); $this->instance->execute(); } public function testInvalidInputFile() { - $this->expectException(\PHPJasper\Exception\InvalidInputFile::class); + $this->expectException(Exception\InvalidInputFile::class); $this->instance->compile('{invalid}')->execute(); } @@ -107,14 +105,14 @@ public function testExecute() public function testListParametersWithWrongInput() { - $this->expectException(\PHPJasper\Exception\InvalidInputFile::class); + $this->expectException(Exception\InvalidInputFile::class); $this->instance->listParameters(''); } public function testProcessWithWrongInput() { - $this->expectException(\PHPJasper\Exception\InvalidInputFile::class); + $this->expectException(Exception\InvalidInputFile::class); $this->instance->process('', '', [ 'format' => 'mp3' @@ -123,7 +121,7 @@ public function testProcessWithWrongInput() public function testProcessWithWrongFormat() { - $this->expectException(\PHPJasper\Exception\InvalidFormat::class); + $this->expectException(Exception\InvalidFormat::class); $this->instance->process('hello_world.jrxml', '', [ 'format' => 'mp3'