-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
125 changed files
with
828 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.gitignore export-ignore | ||
*.dist export-ignore | ||
.travis.yml export-ignore | ||
composer.lock export-ignore | ||
Spec export-ignore | ||
RoboFile.php export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/vendor/ | ||
/build/ | ||
composer.lock | ||
.php_cs.cache |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
|
||
namespace Doyo\Bridge\CodeCoverage\Exception; | ||
|
||
|
||
class HttpException extends \Exception | ||
{ | ||
|
||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
|
||
namespace Doyo\Bridge\CodeCoverage\Http; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
|
||
interface ClientInterface | ||
{ | ||
public function request($method, $uri, array $options = []): ResponseInterface; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
|
||
namespace Doyo\Bridge\CodeCoverage\Listener; | ||
|
||
|
||
use Doyo\Bridge\CodeCoverage\Session\SessionInterface; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
abstract class AbstractSessionListener implements EventSubscriberInterface | ||
{ | ||
protected $session; | ||
|
||
public function __construct( | ||
SessionInterface $session | ||
) | ||
{ | ||
$this->session = $session; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Doyo\Bridge\CodeCoverage\Listener; | ||
|
||
use Doyo\Bridge\CodeCoverage\Event\CoverageEvent; | ||
|
||
class LocalListener extends AbstractSessionListener | ||
{ | ||
public static function getSubscribedEvents() | ||
{ | ||
return [ | ||
CoverageEvent::refresh => 'refresh', | ||
CoverageEvent::start => 'start', | ||
CoverageEvent::complete => 'complete' | ||
]; | ||
} | ||
|
||
public function refresh() | ||
{ | ||
$this->session->reset(); | ||
} | ||
|
||
public function start(CoverageEvent $event) | ||
{ | ||
$session = $this->session; | ||
$testCase = $event->getProcessor()->getCurrentTestCase(); | ||
|
||
$session->setTestCase($testCase); | ||
$session->save(); | ||
} | ||
|
||
public function complete(CoverageEvent $event) | ||
{ | ||
$session = $this->session; | ||
$processor = $event->getProcessor(); | ||
$consoleIO = $event->getConsoleIO(); | ||
|
||
// need to refresh session first | ||
$session->refresh(); | ||
|
||
$processor->merge($session->getProcessor()); | ||
|
||
if($session->hasExceptions()){ | ||
|
||
foreach($session->getExceptions() as $exception){ | ||
$consoleIO->coverageInfo($exception->getMessage()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<?php | ||
|
||
|
||
namespace Doyo\Bridge\CodeCoverage\Listener; | ||
|
||
|
||
use Doyo\Bridge\CodeCoverage\Event\CoverageEvent; | ||
use Doyo\Bridge\CodeCoverage\Exception\HttpException; | ||
use Doyo\Bridge\CodeCoverage\Http\ClientInterface; | ||
use Doyo\Bridge\CodeCoverage\Session\SessionInterface; | ||
|
||
class RemoteListener extends AbstractSessionListener | ||
{ | ||
/** | ||
* @var ClientInterface | ||
*/ | ||
private $httpClient; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $config; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $coverageUrl; | ||
|
||
/** | ||
* @var \Exception[] | ||
*/ | ||
private $exceptions; | ||
|
||
public function __construct( | ||
SessionInterface $session, | ||
ClientInterface $httpClient, | ||
string $coverageUrl, | ||
array $config | ||
) | ||
{ | ||
parent::__construct($session); | ||
|
||
$this->httpClient = $httpClient; | ||
$this->coverageUrl = $coverageUrl; | ||
$this->config = $config; | ||
$this->exceptions = []; | ||
} | ||
|
||
public static function getSubscribedEvents() | ||
{ | ||
return [ | ||
CoverageEvent::refresh => 'refresh', | ||
CoverageEvent::complete => 'complete' | ||
]; | ||
} | ||
|
||
public function refresh() | ||
{ | ||
$client = $this->httpClient; | ||
$session = $this->session; | ||
$body = json_encode($this->config); | ||
$coverageUrl = $this->coverageUrl; | ||
|
||
$options = [ | ||
'body' => $body, | ||
'query' => [ | ||
'action' => 'init', | ||
'session' => $session->getName() | ||
] | ||
]; | ||
|
||
try{ | ||
$client->request('POST', $coverageUrl, $options); | ||
}catch (\Exception $exception){ | ||
$this->exceptions[] = $exception; | ||
} | ||
} | ||
|
||
public function complete(CoverageEvent $event) | ||
{ | ||
$coverageUrl = $this->coverageUrl; | ||
$client = $this->httpClient; | ||
$session = $this->session; | ||
$consoleIO = $event->getConsoleIO(); | ||
|
||
$options = [ | ||
'query' => [ | ||
'action' => 'read', | ||
'session' => $session->getName() | ||
] | ||
]; | ||
|
||
try{ | ||
/* @var SessionInterface $remoteSession */ | ||
$response = $client->request('GET', $coverageUrl, $options); | ||
$remoteSession = $response->getBody()->getContents(); | ||
$remoteSession = unserialize($remoteSession); | ||
$event->getProcessor()->merge($remoteSession->getProcessor()); | ||
}catch (\Exception $exception){ | ||
$this->exceptions[] = $exception; | ||
} | ||
|
||
$exceptions = array_merge($this->exceptions, $remoteSession->getExceptions()); | ||
|
||
$ids = []; | ||
foreach($exceptions as $exception){ | ||
$message = $exception->getMessage(); | ||
$id = md5($message); | ||
if(!in_array($id,$ids)){ | ||
$ids[] = $id; | ||
$consoleIO->coverageInfo($message); | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.