Skip to content

Commit

Permalink
Merge pull request #1 from TheNodi/symfony-5
Browse files Browse the repository at this point in the history
Symfony 5
  • Loading branch information
TheNodi authored Jul 1, 2023
2 parents 944080a + 3be4020 commit e324fa2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
composer.lock
vendor
build
build
.phpunit.result.cache
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
}
],
"require": {
"php": "^7.1.3",
"symfony/process": "^4.1"
"php": "^7.4|^8.0",
"symfony/process": "^5.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^7.0"
"phpunit/phpunit": "^8.0"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 4 additions & 3 deletions tests/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

use TheNodi\PrinterWrapper\Printer;

class ManagerTest extends TestCase
final class ManagerTest extends TestCase
{
/**
* Mock printers
*
* @return $this
*/
protected function mockPrinters()
protected function mockPrinters(): self
{
$this->cli->shouldReceive('run')
->with('lpstat', '-a')
Expand All @@ -31,9 +31,10 @@ protected function mockPrinters()
* Mock default printer
*
* @param string $printer Printer name
*
* @return $this
*/
protected function mockDefaultPrinter($printer)
protected function mockDefaultPrinter(string $printer): self
{
$this->cli->shouldReceive('run')
->with('lpstat', '-d')
Expand Down
11 changes: 6 additions & 5 deletions tests/PrintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@

namespace TheNodi\PrinterWrapper\Tests;

use Mockery;
use TheNodi\PrinterWrapper\Printer;

class PrintTest extends TestCase
final class PrintTest extends TestCase
{
/**
* Mock the run method with given options
*
* @param array $options
* @param string[] $options
*/
protected function mockRunMethod($options = [])
protected function mockRunMethod(array $options = []): void
{
$args = array_merge([
'-d',
'PrinterA',
], $options, ['/tmp/randomfile.txt']);

$this->cli->shouldReceive('run')
->with('lp', $args, \Mockery::type('callable'))
->with('lp', $args, Mockery::type('callable'))
->once()
->andReturn('request id is PrinterA-1 (1 file(s))');
}
Expand All @@ -29,7 +30,7 @@ protected function mockRunMethod($options = [])
*
* @return Printer
*/
protected function getPrinter()
protected function getPrinter(): Printer
{
return new Printer('PrinterA', $this->cli);
}
Expand Down
13 changes: 7 additions & 6 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace TheNodi\PrinterWrapper\Tests;


use Mockery;
use TheNodi\PrinterWrapper\CommandLine;
use TheNodi\PrinterWrapper\PrinterManager;

Expand All @@ -11,7 +12,7 @@ class TestCase extends \PHPUnit\Framework\TestCase
/**
* CommandLine mock
*
* @var CommandLine|\Mockery\MockInterface
* @var CommandLine&\Mockery\MockInterface
*/
protected $cli;

Expand All @@ -20,22 +21,22 @@ class TestCase extends \PHPUnit\Framework\TestCase
*
* @var PrinterManager
*/
protected $manager;
protected PrinterManager $manager;

/**
* @inheritdoc
*/
protected function setUp()
protected function setUp(): void
{
$this->cli = \Mockery::mock(CommandLine::class);
$this->cli = Mockery::mock(CommandLine::class);
$this->manager = new PrinterManager($this->cli);
}

/**
* @inheritdoc
*/
protected function tearDown()
protected function tearDown(): void
{
\Mockery::close();
Mockery::close();
}
}

0 comments on commit e324fa2

Please sign in to comment.