Skip to content
Open
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
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ language: php

php:
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4

cache:
directories:
Expand Down
12 changes: 5 additions & 7 deletions src/Client/Console.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<?php
declare(strict_types=1);
/**
* Created by PhpStorm.
* User: nassim.kirouane
* Date: 11/18/18
* Time: 3:41 PM
*/

namespace Imposter\Client;

Expand Down Expand Up @@ -38,6 +32,10 @@ public function startImposter()
if ($this->configPath) {
$command .= " -c $this->configPath";
}
pclose(popen("$command &", 'r'));
$handler = popen("$command &", 'r');

// Since php 7.4, the speed of php is so fast that there is a race condition without this waiting time
\usleep(1000000);
pclose($handler);
}
}
2 changes: 1 addition & 1 deletion src/Server/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
class Server
{
const PORT = 2424;
const PORT = 2424;

/**
* @var Container
Expand Down
2 changes: 1 addition & 1 deletion test/api/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function logPath()
->returnBody('{"response" :"okay"}')
->send();

$client = new \GuzzleHttp\Client();
$client = new \GuzzleHttp\Client();
try {

$client->post('http://localhost:8081/users/2')->getBody()->getContents();
Expand Down
14 changes: 11 additions & 3 deletions test/unit/Client/HttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Imposter\Client;


use Imposter\Common\Model\Mock;
use Imposter\Common\Model\MockAbstract;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -37,7 +36,8 @@ public function insertMockWithExceptions($code, $content, $withException)
self::expectException(\Exception::class);
}

$mock = \Mockery::mock(MockAbstract::class);
$mock = new MockAsset(8081);

$response = \Mockery::mock(\Psr\Http\Message\ResponseInterface::class);
$response->shouldReceive('getBody->getContents')->andReturn($content);
$response->shouldReceive('getStatusCode')->andReturn($code);
Expand All @@ -46,7 +46,7 @@ public function insertMockWithExceptions($code, $content, $withException)
$client->shouldReceive('post')->andReturn($response);
$http = new Http($client, \Mockery::mock(Console::class));

$returnedMock =$http->insert($mock);
$returnedMock = $http->insert($mock);
self::assertInstanceOf(MockAbstract::class, $returnedMock);
}

Expand Down Expand Up @@ -226,4 +226,12 @@ public function tearDown()
$this->addToAssertionCount(\Mockery::getContainer()->mockery_getExpectationCount());
\Mockery::close();
}
}

class MockAsset extends MockAbstract
{
public function toString(): string
{
return 'asset';
}
}