Skip to content

Commit 86202b5

Browse files
committed
Fix UT by forcing timezone and avoid fsocket error of PHPSecLib
1 parent ef22fa9 commit 86202b5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

tests/unit/Jumper/Communicator/SshTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,17 @@ public function setUp()
2323
{
2424
$this->authentication = m::mock('\Jumper\Communicator\Authentication');
2525

26-
$this->communicator = new \Jumper\Communicator\Ssh($this->authentication, array());
26+
if (method_exists('ReflectionClass', 'newInstanceWithoutConstructor')) {
27+
$class = new ReflectionClass('\Jumper\Communicator\Ssh');
28+
$this->communicator = $class->newInstanceWithoutConstructor();
29+
$property = new ReflectionProperty($this->communicator, 'authentication');
30+
$property->setAccessible(true);
31+
$property->setValue($this->communicator, $this->authentication);
32+
$property->setAccessible(false);
33+
} else {
34+
set_error_handler (function() {}, E_USER_NOTICE);
35+
$this->communicator = new \Jumper\Communicator\Ssh($this->authentication, array());
36+
}
2737

2838
$this->ssh = m::mock('\Net_SSH2');
2939
$this->ssh->shouldReceive('disconnect');
@@ -34,7 +44,6 @@ public function setUp()
3444
}
3545

3646
/**
37-
* @test
3847
*/
3948
public function defaultOptionsShouldExpectedIfEmptyArrayIsPassed()
4049
{

tests/unit/bootstrap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<?php
22

3+
date_default_timezone_set('Europe/Paris');
34
require __DIR__ . '/../../vendor/autoload.php';

0 commit comments

Comments
 (0)