PK °BV/X©´
phpunit.xml.distnu W+A„¶
tests
vendor/behat/mink/driver-testsuite/tests
./src/Behat/Mink/Driver
PK °BV|l6¿í í .travis.ymlnu W+A„¶ language: php
php: [5.3, 5.4, 5.5, 5.6, hhvm]
before_script:
- export WEB_FIXTURES_HOST=http://localhost
# Install deps
- composer install --dev --prefer-source
- sudo apt-get update > /dev/null
- sudo apt-get install -y --force-yes apache2 libapache2-mod-php5
- sudo sed -i -e "s,/var/www,$(pwd)/vendor/behat/mink/driver-testsuite/web-fixtures,g" /etc/apache2/sites-available/default
- sudo /etc/init.d/apache2 restart
- npm install zombie
- export NODE_PATH="$(pwd)/node_modules"
- export PATH="/usr/local/share/npm/bin:$PATH"
script: phpunit -v --coverage-clover=coverage.clover
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
PK °BVt‡bL L
composer.jsonnu W+A„¶ {
"name": "behat/mink-zombie-driver",
"description": "Zombie.js driver for Mink framework",
"keywords": ["zombie", "headless", "javascript", "ajax", "testing", "browser"],
"homepage": "http://mink.behat.org/",
"type": "mink-driver",
"license": "MIT",
"authors": [
{
"name": "Pascal Cremer",
"email": "b00gizm@gmail.com",
"homepage": "http://github.com/b00gizm"
},
{
"name": "Konstantin Kudryashov",
"email": "ever.zet@gmail.com",
"homepage": "http://everzet.com"
}
],
"require": {
"php": ">=5.3.1",
"behat/mink": "~1.6@dev",
"symfony/process": "~2.1"
},
"autoload": {
"psr-0": {
"Behat\\Mink\\Driver": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Behat\\Mink\\Tests\\Driver\\": "tests"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev"
}
}
}
PK °BVË66‡
CHANGELOG.mdnu W+A„¶ 1.2.0 / 2014-09-26
==================
BC break:
* Rewrote the driver based on Zombie 2.0 rather than the old 1.x versions
* Changed the behavior of `getValue` for checkboxes according to the BC break in Mink 1.6
New features:
* Added the support of select elements in `setValue`
* Implemented `getOuterHtml`
* Added support for request headers
* Implemented `submitForm`
* Implemented `isSelected`
Bug fixes:
* Fixed the selection of options for multiple selects to ensure the change event is triggered only once
* Fixed the selection of options for radio groups
* Fixed `getValue` for radio groups
* Fixed the retrieval of response headers
* Fixed a leak of outdated references in the node server when changing page
* Fixed the resetting of the driver to reset everything
* Fixed the code to throw exceptions for invalid usages of the driver
* Fixed handling of errors to throw exceptions in the driver rather than crashing the node server
* Fixed `evaluateScript` and `executeScript` to support all syntaxes required by the Mink API
* Fixed `getContent` to return the source of the page without decoding entities
* Fixed the removal of cookies
* Fixed the basic auth implementation
Testing:
* Updated the testsuite to use the new Mink 1.6 driver testsuite
* Added testing on HHVM
PK °BV
Ç ‡ tests/ZombieConfig.phpnu W+A„¶ setNodeModulesPath($_SERVER['NODE_MODULES_PATH']);
}
return new ZombieDriver($server);
}
/**
* {@inheritdoc}
*/
public function skipMessage($testCase, $test)
{
if (
'Behat\Mink\Tests\Driver\Form\Html5Test' === $testCase
&& in_array($test, array(
'testHtml5FormInputAttribute',
'testHtml5FormButtonAttribute',
'testHtml5FormOutside',
'testHtml5FormRadioAttribute',
))
) {
return 'Zombie.js doesn\'t HTML5 form attributes. See https://github.com/assaf/zombie/issues/635';
}
if (
'Behat\Mink\Tests\Driver\Js\JavascriptEvaluationTest' === $testCase
&& 'testWait' === $test
) {
return 'Zombie automatically waits for events to fire, so the wait test is irrelevant';
}
if ('Behat\Mink\Tests\Driver\Js\ChangeEventTest' === $testCase && 'testIssue178' === $test) {
return 'Zombie does not trigger the keyup event when writing a value in a text input to simulate keyboard';
}
return parent::skipMessage($testCase, $test);
}
}
PK °BVå5ÌX² ² 2 tests/Custom/NodeJS/server-fixtures/test_server.jsnu W+A„¶ var net = require('net');
net.createServer(function (stream) {
// This server does nothing.
}).listen(8124, '127.0.0.1');
console.log('Server running at 127.0.0.1:8124');
PK °BV
°—A 3 tests/Custom/NodeJS/server-fixtures/empty_server.jsnu W+A„¶ // Nothing in here.
PK °BVãkÏ\3 3 " tests/Custom/NodeJS/ServerTest.phpnu W+A„¶ serverScript = strtr($this->getServerScript(), array(
'%host%' => $this->host,
'%port%' => $this->port,
'%modules_path%' => $this->nodeModulesPath,
));
return '/path/to/server';
}
}
class ServerTest extends \PHPUnit_Framework_TestCase
{
public function testCreateServerWithDefaults()
{
$server = new TestServer();
$this->assertEquals('127.0.0.1', $server->getHost());
$this->assertEquals(8124, $server->getPort());
$this->assertEquals('node', $server->getNodeBin());
$this->assertEquals('/path/to/server', $server->getServerPath());
$this->assertEquals(2000000, $server->getThreshold());
$this->assertEquals('', $server->getNodeModulesPath());
$expected = <<assertEquals($expected, $server->serverScript);
}
public function testCreateCustomServer()
{
$server = new TestServer(
'123.123.123.123',
1234,
null,
null,
5000000,
'../../'
);
$this->assertEquals('123.123.123.123', $server->getHost());
$this->assertEquals(1234, $server->getPort());
$this->assertEquals('node', $server->getNodeBin());
$this->assertEquals('/path/to/server', $server->getServerPath());
$this->assertEquals(5000000, $server->getThreshold());
$this->assertEquals('../../', $server->getNodeModulesPath());
$expected = <<assertEquals($expected, $server->serverScript);
}
public function testSetNodeModulesPath()
{
$server = new TestServer();
$server->setNodeModulesPath('../../');
$this->assertEquals('../../', $server->getNodeModulesPath());
$expected = <<assertEquals($expected, $server->serverScript);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testSetNodeModulesPathWithInvalidPath()
{
$server = new TestServer();
$server->setNodeModulesPath('/does/not/exist/');
}
/**
* @expectedException \InvalidArgumentException
*/
public function testSetNodeModulesPathWithoutTrailingSlash()
{
$server = new TestServer();
$server->setNodeModulesPath('../..');
}
/**
* @expectedException \RuntimeException
*/
public function testStartServerWithNonExistingServerScript()
{
$server = new TestServer('127.0.0.1', 8124, null, '/does/not/exist');
$server->start();
}
/**
* @expectedException \RuntimeException
* @expectedExceptionMessage Server did not respond in time: (1) [Stopped]
*/
public function testStartServerThatDoesNotRespondInTime()
{
$process = $this->getNotRespondingServerProcessMock();
$process->expects($this->once())
->method('start');
$serverPath = __DIR__.'/server-fixtures/test_server.js';
$server = new TestServer('127.0.0.1', 8124, null, $serverPath, 10000);
$server->start($process);
}
/**
* @expectedException \RuntimeException
* @expectedExceptionMessage Server process has been terminated: (1) [TROLOLOLO]
*/
public function testStartServerThatWasTerminated()
{
$process = $this->getTerminatedServerProcessMock();
$process->expects($this->once())
->method('start');
$serverPath = __DIR__.'/server-fixtures/test_server.js';
$server = new TestServer('127.0.0.1', 8124, null, $serverPath, 10000);
$server->start($process);
}
public function testStartServerSuccessfully()
{
$host = '127.0.0.1';
$port = 8124;
$process = $this->getWorkingServerProcessMock($host, $port);
$process->expects($this->once())
->method('start');
$serverPath = __DIR__.'/server-fixtures/test_server.js';
$server = new TestServer($host, $port, null, $serverPath, 10000);
try {
$server->start($process);
$this->assertInstanceOf(
'Behat\Mink\Driver\NodeJS\Connection',
$server->getConnection()
);
} catch (\RuntimeException $ex) {
$this->fail('No exception should have been thrown here');
}
}
public function testStopServer()
{
$host = '127.0.0.1';
$port = 8124;
$process = $this->getWorkingServerProcessMock($host, $port);
$process->expects($this->atLeastOnce())
->method('stop');
$serverPath = __DIR__.'/server-fixtures/test_server.js';
$server = new TestServer($host, $port, null, $serverPath, 10000);
$server->start($process);
$server->stop();
}
public function testIsRunning()
{
$host = '127.0.0.1';
$port = 8124;
$serverPath = __DIR__.'/server-fixtures/test_server.js';
$server = new TestServer($host, $port, null, $serverPath, 10000);
$this->assertFalse($server->isRunning());
$process = $this->getWorkingServerProcessMock($host, $port);
$server->start($process);
$this->assertTrue($server->isRunning());
$process = $this->getTerminatedServerProcessMock();
try {
$server->start($process);
} catch (\RuntimeException $ex) {
// ignore error
}
$this->assertFalse($server->isRunning());
}
protected function getNotRespondingServerProcessMock()
{
$process = $this->getMockBuilder('Symfony\Component\Process\Process')
->disableOriginalConstructor()
->getMock();
$process->expects($this->any())
->method('isRunning')
->will($this->returnValue(true));
$process->expects($this->any())
->method('getOutput')
->will($this->returnValue(''));
$process->expects($this->any())
->method('getExitCode')
->will($this->returnValue(1));
return $process;
}
protected function getTerminatedServerProcessMock()
{
$process = $this->getMockBuilder('Symfony\Component\Process\Process')
->disableOriginalConstructor()
->getMock();
$process->expects($this->any())
->method('isRunning')
->will($this->returnValue(false));
$process->expects($this->any())
->method('getErrorOutput')
->will($this->returnValue('TROLOLOLO'));
$process->expects($this->any())
->method('getExitCode')
->will($this->returnValue(1));
return $process;
}
protected function getWorkingServerProcessMock($host, $port)
{
$process = $this->getMockBuilder('Symfony\Component\Process\Process')
->disableOriginalConstructor()
->getMock();
$process->expects($this->any())
->method('isRunning')
->will($this->returnValue(true));
$process->expects($this->once())
->method('getOutput')
->will($this->returnValue(sprintf("server started on %s:%s", $host, $port)));
return $process;
}
}
PK °BVaâÎ$ $ tests/Custom/ExtraTest.phpnu W+A„¶ getSession();
$session->setRequestHeader('user-agent', 'foo bar');
$session->visit($this->pathTo('/headers.php'));
$this->assertContains('foo bar', $session->getPage()->getText());
}
// TODO check whether this is covered by upstream test
public function testSetRequestHeader()
{
$this->getSession()->setRequestHeader('foo', 'bar');
$this->getSession()->visit($this->pathTo('/headers.php'));
$this->assertContains('[HTTP_FOO] => bar', $this->getSession()->getPage()->getText());
}
}
PK °BV³<