Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Update dependencies and fix PHPStan paths #2

Merged
merged 2 commits into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ matrix:
- php: 7.1
env: CS_CHECK=1 STATIC_ANALYSIS=1
- php: 7.2
- php: 7.3
env: CODE_COVERAGE=1

cache:
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"zendframework/zend-servicemanager": "^3.3"
},
"require-dev": {
"phpstan/phpstan": "^0.9.1",
"phpstan/phpstan-phpunit": "^0.9.3",
"phpunit/phpunit": "^7.0",
"slam/php-cs-fixer-extensions": "^1.13",
"slam/php-debug-r": "^1.2",
"slam/phpstan-extensions": "^1.0",
"thecodingmachine/phpstan-strict-rules": "^0.9.0"
"phpstan/phpstan": "^0.11",
"phpstan/phpstan-phpunit": "^0.11",
"phpunit/phpunit": "^7.5",
"slam/php-cs-fixer-extensions": "^1.18",
"slam/php-debug-r": "^1.6",
"slam/phpstan-extensions": "^3.6",
"thecodingmachine/phpstan-strict-rules": "^0.11"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 3 additions & 3 deletions lib/Transport/Smtp.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public function send(ZendMessage $message): void
$connection = $this->getConnection();

if ($connection instanceof SlamProtocol\TimeKeeperProtocolInterface
and $this->reuseTimeLimit >= 0
and $connection->getStartTime()
and ((\time() - $connection->getStartTime()) >= $this->reuseTimeLimit)
&& $this->reuseTimeLimit >= 0
&& $connection->getStartTime()
&& ((\time() - $connection->getStartTime()) >= $this->reuseTimeLimit)
) {
$connection->disconnect();
}
Expand Down
4 changes: 3 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ includes:
- vendor/slam/phpstan-extensions/conf/thecodingmachine-rules.neon

parameters:
paths:
- lib/
- tests/
ignoreErrors:
- '#Parameter \#1 \$originalProtocol of class Slam\\Zend\\Mail\\Protocol\\TimeKeeperSmtpProxy constructor expects Zend\\Mail\\Protocol\\Smtp, PHPUnit\\Framework\\MockObject\\MockObject given#'
- '#Parameter \#1 \$useCompleteQuit of method Zend\\Mail\\Protocol\\Smtp::setUseCompleteQuit\(\) expects int, false given#'
- '#Slam\\Zend\\Mail\\Protocol\\TimeKeeperSmtpProxy::__construct\(\) does not call parent constructor from Zend\\Mail\\Protocol\\Smtp#'
- '#Call to an undefined method Zend\\Mail\\Protocol\\Smtp::setUsername\(\)#'
- '#Call to an undefined method Zend\\Mail\\Protocol\\Smtp::getUsername\(\)#'
Expand Down
18 changes: 9 additions & 9 deletions tests/Protocol/TimeKeeperSmtpProxyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testProxyPublicMethodsExceptQuitOne(string $smtpClass): void

foreach ($methods as $methodName => $blob) {
list($arguments, $return) = $blob;
$invocationMocker = $zendSmtp->expects($this->once());
$invocationMocker = $zendSmtp->expects(static::once());
$invocationMocker->method($methodName);

if (\count($arguments)) {
Expand All @@ -61,15 +61,15 @@ public function testProxyPublicMethodsExceptQuitOne(string $smtpClass): void
}

$zendSmtp
->expects($this->once())
->expects(static::once())
->method('setUseCompleteQuit')
->with($this->identicalTo(false))
->with(static::identicalTo(false))
;

$protocol = new TimeKeeperSmtpProxy($zendSmtp);
foreach ($methods as $methodName => $blob) {
list($arguments, $return) = $blob;
$this->assertSame($return, $protocol->{$methodName}(...$arguments));
static::assertSame($return, $protocol->{$methodName}(...$arguments));
}
}

Expand All @@ -86,19 +86,19 @@ public function provideKnownSmtpTypes(): array
public function testAccountTheStartTime(): void
{
$zendProtocolSmtpMock = $this->createMock(ZendProtocolSmtp::class);
$zendProtocolSmtpMock->expects($this->once())->method('connect')->willReturn(true);
$zendProtocolSmtpMock->expects($this->once())->method('disconnect');
$zendProtocolSmtpMock->expects(static::once())->method('connect')->willReturn(true);
$zendProtocolSmtpMock->expects(static::once())->method('disconnect');
$protocol = new TimeKeeperSmtpProxy($zendProtocolSmtpMock);

$this->assertNull($protocol->getStartTime());
static::assertNull($protocol->getStartTime());

$protocol->connect();
$protocol->helo();

$this->assertGreaterThan(0, $protocol->getStartTime());
static::assertGreaterThan(0, $protocol->getStartTime());

$protocol->disconnect();

$this->assertNull($protocol->getStartTime());
static::assertNull($protocol->getStartTime());
}
}
16 changes: 8 additions & 8 deletions tests/Transport/SmtpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
use Zend\Mail\Message;

/**
* @covers \Slam\Zend\Mail\Transport\Smtp
* @covers \Slam\Zend\Mail\Protocol\TimeKeeperSmtpProxyDelegatorFactory
* @covers \Slam\Zend\Mail\Transport\Smtp
*/
final class SmtpTest extends TestCase
{
Expand All @@ -21,7 +21,7 @@ public function testProtocolsAreProxied(): void

$pluginManager = $transport->getPluginManager();

$this->assertInstanceOf(TimeKeeperSmtpProxy::class, $pluginManager->get('smtp'));
static::assertInstanceOf(TimeKeeperSmtpProxy::class, $pluginManager->get('smtp'));
}

public function testAutomaticallyDisconnectAndRiconnectBetweenTwoConsecutivesSendsIfTooMuchTimeIsPassedInOrderToAvoidReuseTimeLimitBond(): void
Expand All @@ -37,28 +37,28 @@ public function testAutomaticallyDisconnectAndRiconnectBetweenTwoConsecutivesSen
$transport = new Smtp();
$transport->setConnection($protocol);

$this->assertGreaterThan(0, $transport->getReuseTimeLimit());
static::assertGreaterThan(0, $transport->getReuseTimeLimit());

$transport->setReuseTimeLimit(0);

$this->assertSame(0, $protocol->getDisconnectCount());
static::assertSame(0, $protocol->getDisconnectCount());

$transport->send($message);

$this->assertSame(0, $protocol->getDisconnectCount());
static::assertSame(0, $protocol->getDisconnectCount());

$transport->send($message);

$this->assertSame(1, $protocol->getDisconnectCount());
static::assertSame(1, $protocol->getDisconnectCount());

$transport->send($message);

$this->assertSame(2, $protocol->getDisconnectCount());
static::assertSame(2, $protocol->getDisconnectCount());

$transport->setReuseTimeLimit(999);

$transport->send($message);

$this->assertSame(2, $protocol->getDisconnectCount());
static::assertSame(2, $protocol->getDisconnectCount());
}
}