Skip to content

Commit

Permalink
Merge pull request #117 from aik099/remove-event-dispatcher
Browse files Browse the repository at this point in the history
Removed event dispatcher
  • Loading branch information
aik099 authored Mar 12, 2024
2 parents 28c5c12 + 5dce3df commit e89ac7e
Show file tree
Hide file tree
Showing 37 changed files with 266 additions and 1,199 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Bumped minimum PHP version to 5.6.
- Changed default OS from "Windows 7" to "Windows 10" for BrowserStack/SauceLabs browser configurations.
- Allow using self-signed/invalid SSL certificates during testing on the SauceLabs by default.
- Rewritten library object communication mechanism (the event dispatcher is no longer used). Update any custom session strategy/browser configuration implementations.

### Fixed
...
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"php": ">=5.6",
"behat/mink": "~1.6@dev",
"behat/mink-selenium2-driver": "~1.2",
"symfony/event-dispatcher": "~2.4|~3.0",
"phpunit/phpunit": ">=4.8.35 <5|>=5.4.3"
},

Expand Down
78 changes: 1 addition & 77 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@

use aik099\PHPUnit\APIClient\IAPIClient;
use aik099\PHPUnit\BrowserTestCase;
use aik099\PHPUnit\Event\TestEndedEvent;
use aik099\PHPUnit\Event\TestEvent;
use aik099\PHPUnit\Framework\TestResult;
use aik099\PHPUnit\MinkDriver\DriverFactoryRegistry;
use Behat\Mink\Driver\Selenium2Driver;
use Behat\Mink\Session;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

/**
* Browser configuration tailored to use with API-based service.
Expand All @@ -42,18 +40,15 @@ abstract class ApiBrowserConfiguration extends BrowserConfiguration
/**
* Creates browser configuration.
*
* @param EventDispatcherInterface $event_dispatcher Event dispatcher.
* @param DriverFactoryRegistry $driver_factory_registry Driver factory registry.
* @param DriverFactoryRegistry $driver_factory_registry Driver factory registry.
*/
public function __construct(
EventDispatcherInterface $event_dispatcher,
DriverFactoryRegistry $driver_factory_registry
) {
public function __construct(DriverFactoryRegistry $driver_factory_registry)
{
$this->defaults['driver'] = 'selenium2';
$this->defaults['apiUsername'] = '';
$this->defaults['apiKey'] = '';

parent::__construct($event_dispatcher, $driver_factory_registry);
parent::__construct($driver_factory_registry);
}

/**
Expand Down Expand Up @@ -137,22 +132,14 @@ public function getBrowserName()
}

/**
* Hook, called from "BrowserTestCase::setUp" method.
*
* @param TestEvent $event Test event.
*
* @return void
* @inheritDoc
*/
public function onTestSetup(TestEvent $event)
public function onTestSetup(BrowserTestCase $test_case)
{
if ( !$event->validateSubscriber($this->getTestCase()) ) {
return;
}

parent::onTestSetup($event);
parent::onTestSetup($test_case);

$desired_capabilities = $this->getDesiredCapabilities();
$desired_capabilities[self::NAME_CAPABILITY] = $this->getJobName($event->getTestCase());
$desired_capabilities[self::NAME_CAPABILITY] = $this->getJobName($test_case);

if ( getenv('BUILD_NUMBER') ) {
$desired_capabilities[self::BUILD_NUMBER_CAPABILITY] = getenv('BUILD_NUMBER'); // Jenkins.
Expand Down Expand Up @@ -181,33 +168,23 @@ protected function getJobName(BrowserTestCase $test_case)
}

/**
* Hook, called from "BrowserTestCase::run" method.
*
* @param TestEndedEvent $event Test ended event.
*
* @return void
* @inheritDoc
*/
public function onTestEnded(TestEndedEvent $event)
public function onTestEnded(BrowserTestCase $test_case, TestResult $test_result)
{
if ( !$event->validateSubscriber($this->getTestCase()) ) {
return;
}

parent::onTestEnded($event);
parent::onTestEnded($test_case, $test_result);

$session = $event->getSession();
$session = $test_case->getSession(false);

if ( $session === null || !$session->isStarted() ) {
// Session wasn't used in particular test.
return;
}

$test_case = $event->getTestCase();

$this->getAPIClient()->updateStatus(
$this->getSessionId($session),
$this->getTestStatus($test_case, $event->getTestResult()),
$this->getTestStatusMessage($test_case, $event->getTestResult())
$this->getTestStatus($test_case, $test_result),
$this->getTestStatusMessage($test_case, $test_result)
);
}

Expand Down
Loading

0 comments on commit e89ac7e

Please sign in to comment.