add psalm and travis check

This commit is contained in:
Dominik Liebler
2019-08-31 14:31:01 +02:00
parent 88bd6ab7f1
commit 5fb2980b45
17 changed files with 1215 additions and 45 deletions

View File

@@ -2,6 +2,7 @@
namespace DesignPatterns\Structural\Facade\Tests;
use DesignPatterns\Structural\Facade\Bios;
use DesignPatterns\Structural\Facade\Facade;
use DesignPatterns\Structural\Facade\OperatingSystem;
use PHPUnit\Framework\TestCase;
@@ -10,27 +11,20 @@ class FacadeTest extends TestCase
{
public function testComputerOn()
{
/** @var OperatingSystem|\PHPUnit_Framework_MockObject_MockObject $os */
$os = $this->createMock('DesignPatterns\Structural\Facade\OperatingSystem');
$os = $this->createMock(OperatingSystem::class);
$os->method('getName')
->will($this->returnValue('Linux'));
$bios = $this->getMockBuilder('DesignPatterns\Structural\Facade\Bios')
->setMethods(['launch', 'execute', 'waitForKeyPress'])
->disableAutoload()
->getMock();
$bios = $this->createMock(Bios::class);
$bios->expects($this->once())
->method('launch')
$bios->method('launch')
->with($os);
/** @noinspection PhpParamsInspection */
$facade = new Facade($bios, $os);
// the facade interface is simple
$facade->turnOn();
// but you can also access the underlying components
$this->assertSame('Linux', $os->getName());
}
}

View File

@@ -20,6 +20,6 @@ class HeavyBankAccount implements BankAccount
// years and decades ago must be fetched from a database or web service
// and the balance must be calculated from it
return array_sum($this->transactions);
return (int) array_sum($this->transactions);
}
}

View File

@@ -9,9 +9,6 @@ use PHPUnit\Framework\TestCase;
class RegistryTest extends TestCase
{
/**
* @var Service|MockObject
*/
private $service;
protected function setUp(): void
@@ -21,6 +18,7 @@ class RegistryTest extends TestCase
public function testSetAndGetLogger()
{
/** @noinspection PhpParamsInspection */
Registry::set(Registry::LOGGER, $this->service);
$this->assertSame($this->service, Registry::get(Registry::LOGGER));