Skip to content

Commit

Permalink
Merge branch '1.9' into 1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Oct 8, 2023
2 parents d45e130 + 1b78aa4 commit d076f8d
Show file tree
Hide file tree
Showing 16 changed files with 84 additions and 84 deletions.
2 changes: 1 addition & 1 deletion src/BrowserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function __construct(string $chromeBinary = null)
*/
public function createBrowser(?array $options = null): ProcessAwareBrowser
{
$options = $options ?? $this->options;
$options ??= $this->options;

// create logger from options
$logger = self::createLogger($options);
Expand Down
2 changes: 1 addition & 1 deletion src/Communication/ResponseReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function waitForResponse(int $timeout = null): Response
return $this->getResponse();
}

$timeout = $timeout ?? $this->connection->getSendSyncDefaultTimeout();
$timeout ??= $this->connection->getSendSyncDefaultTimeout();

return Utils::tryWithTimeout($timeout * 1000, $this->waitForResponseGenerator());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/BrowserFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testUserAgentOption(): void

$response = $page->evaluate('navigator.userAgent')->getReturnValue();

self::assertEquals('foo bar baz', $response);
self::assertSame('foo bar baz', $response);
}

public function testAddHeaders(): void
Expand Down
14 changes: 7 additions & 7 deletions tests/BrowsingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ public function testPageNavigateEvaluate(): void
// initial navigation
$page = $this->openSitePage('index.html');
$title = $page->evaluate('document.title')->getReturnValue();
self::assertEquals('foo', $title);
self::assertSame('foo', $title);

// navigate again
$page->navigate(self::sitePath('a.html'))->waitForNavigation();
$title = $page->evaluate('document.title')->getReturnValue();
self::assertEquals('a - test', $title);
self::assertSame('a - test', $title);
}

public function testFormSubmission(): void
Expand All @@ -72,7 +72,7 @@ public function testFormSubmission(): void
);

$evaluation->waitForPageReload();
self::assertEquals('hello', $page->evaluate('document.querySelector("#value").innerHTML')->getReturnValue());
self::assertSame('hello', $page->evaluate('document.querySelector("#value").innerHTML')->getReturnValue());
}

public function testGetCurrentUrl(): void
Expand All @@ -81,11 +81,11 @@ public function testGetCurrentUrl(): void

$page->getSession()->getConnection()->readData();

self::assertEquals('about:blank', $page->getCurrentUrl());
self::assertSame('about:blank', $page->getCurrentUrl());

$page->navigate(self::sitePath('a.html'))->waitForNavigation();

self::assertEquals(self::sitePath('a.html'), $page->getCurrentUrl());
self::assertSame(self::sitePath('a.html'), $page->getCurrentUrl());
}

public function testPageNavigationLocalNotFoundUrl(): void
Expand Down Expand Up @@ -127,12 +127,12 @@ public function testGetPagesNavigateEvaluate(): void
// initial navigation
$page = $this->openSitePage('index.html');
$title = $page->evaluate('document.title')->getReturnValue();
self::assertEquals('foo', $title);
self::assertSame('foo', $title);

// navigate again
$page->navigate(self::sitePath('a.html'))->waitForNavigation();
$title = $page->evaluate('document.title')->getReturnValue();
self::assertEquals('a - test', $title);
self::assertSame('a - test', $title);
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Communication/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public function testCreateSession(): void
$session = $connection->createSession('baz-qux');

self::assertInstanceOf(Session::class, $session);
self::assertEquals('foo-bar', $session->getSessionId());
self::assertEquals('baz-qux', $session->getTargetId());
self::assertSame('foo-bar', $session->getSessionId());
self::assertSame('baz-qux', $session->getTargetId());
self::assertSame($connection, $session->getConnection());
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Communication/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class MessageTest extends TestCase
public function testMessage(): void
{
$message = new Message('foo', ['bar' => 'baz']);
self::assertEquals(Message::getLastMessageId(), $message->getId());
self::assertEquals('foo', $message->getMethod());
self::assertSame(Message::getLastMessageId(), $message->getId());
self::assertSame('foo', $message->getMethod());
self::assertEquals(['bar' => 'baz'], $message->getParams());

self::assertEquals(
Expand All @@ -32,9 +32,9 @@ public function testMessage(): void
);

$message2 = new Message('qux', ['quux' => 'corge']);
self::assertEquals(Message::getLastMessageId(), $message2->getId());
self::assertSame(Message::getLastMessageId(), $message2->getId());
self::assertNotSame($message->getId(), $message2->getId());
self::assertEquals('qux', $message2->getMethod());
self::assertSame('qux', $message2->getMethod());
self::assertEquals(['quux' => 'corge'], $message2->getParams());
}
}
4 changes: 2 additions & 2 deletions tests/Communication/ResponseReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ public function testWaitForResponseIsAtomic(): void
// wait for response should not read the second message (method:qux.quux)
$response = $responseReader->waitForResponse(1);
self::assertEquals(['id' => $message->getId(), 'foo' => 'qux'], $response->getData());
self::assertEquals(0, $emitWatcher->emittedCount);
self::assertSame(0, $emitWatcher->emittedCount);

// next call to read line should read the second message (method:qux.quux)
$connection->readLine();
self::assertEquals(1, $emitWatcher->emittedCount);
self::assertSame(1, $emitWatcher->emittedCount);
}

public function testExceptionNoResponse(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Communication/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testMessage(): void
self::assertSame($message, $response->getMessage());
self::assertTrue($response->isSuccessful());
self::assertTrue(isset($response['bar']));
self::assertEquals('foo', $response['bar']);
self::assertSame('foo', $response['bar']);
self::assertEquals(['id' => $message->getId(), 'bar' => 'foo'], $response->getData());
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Communication/SessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public function testSession(): void
$connection = new Connection($this->mockSocket);
$session = new Session('foo', 'bar', $connection);

self::assertEquals('foo', $session->getTargetId());
self::assertEquals('bar', $session->getSessionId());
self::assertSame('foo', $session->getTargetId());
self::assertSame('bar', $session->getSessionId());
self::assertSame($connection, $session->getConnection());
}

Expand Down
26 changes: 13 additions & 13 deletions tests/CookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public function testReadCookies(): void
self::assertInstanceOf(CookiesCollection::class, $cookies);
self::assertCount(1, $cookies);

self::assertEquals($cookies->getAt(0)->getName(), 'foo');
self::assertEquals($cookies->getAt(0)->getValue(), 'bar');
self::assertSame('foo', $cookies->getAt(0)->getName());
self::assertSame('bar', $cookies->getAt(0)->getValue());
}

public function testGetAllCookies(): void
Expand All @@ -70,8 +70,8 @@ public function testGetAllCookies(): void
self::assertInstanceOf(CookiesCollection::class, $cookies);
self::assertCount(1, $cookies);

self::assertEquals($cookies->getAt(0)->getName(), 'foo');
self::assertEquals($cookies->getAt(0)->getValue(), 'bar');
self::assertSame('foo', $cookies->getAt(0)->getName());
self::assertSame('bar', $cookies->getAt(0)->getValue());
}

public function testSetCookies(): void
Expand All @@ -92,9 +92,9 @@ public function testSetCookies(): void
self::assertInstanceOf(CookiesCollection::class, $cookies);
self::assertCount(1, $cookies);

self::assertEquals($cookies->getAt(0)->getName(), 'baz');
self::assertEquals($cookies->getAt(0)->getValue(), 'qux');
self::assertEquals($cookies->getAt(0)->getDomain(), 'foo.bar');
self::assertSame('baz', $cookies->getAt(0)->getName());
self::assertSame('qux', $cookies->getAt(0)->getValue());
self::assertSame('foo.bar', $cookies->getAt(0)->getDomain());

// Set cookie for current page
$page->navigate(self::sitePath('a.html'))->waitForNavigation();
Expand All @@ -108,12 +108,12 @@ public function testSetCookies(): void
self::assertInstanceOf(CookiesCollection::class, $cookies);
self::assertCount(2, $cookies);

self::assertEquals($cookies->getAt(1)->getName(), 'quux');
self::assertEquals($cookies->getAt(1)->getValue(), 'corge');
self::assertEquals($cookies->getAt(1)->getDomain(), 'localhost');
self::assertSame('quux', $cookies->getAt(1)->getName());
self::assertSame('corge', $cookies->getAt(1)->getValue());
self::assertSame('localhost', $cookies->getAt(1)->getDomain());

self::assertEquals($cookies->getAt(0)->getName(), 'baz');
self::assertEquals($cookies->getAt(0)->getValue(), 'qux');
self::assertEquals($cookies->getAt(0)->getDomain(), 'foo.bar');
self::assertSame('baz', $cookies->getAt(0)->getName());
self::assertSame('qux', $cookies->getAt(0)->getValue());
self::assertSame('foo.bar', $cookies->getAt(0)->getDomain());
}
}
8 changes: 4 additions & 4 deletions tests/Cookies/CookiesCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function testFilterBy(): void
$newCookies = $cookies->filterBy('name', 'foo');

self::assertCount(2, $newCookies);
self::assertEquals('bar', $newCookies->getAt(0)->getValue());
self::assertEquals('baz', $newCookies->getAt(1)->getValue());
self::assertSame('bar', $newCookies->getAt(0)->getValue());
self::assertSame('baz', $newCookies->getAt(1)->getValue());
}

public function testFindOneBy(): void
Expand All @@ -47,7 +47,7 @@ public function testFindOneBy(): void
$cookieFoo = $cookies->findOneBy('name', 'foo');
$cookieQux = $cookies->findOneBy('name', 'qux');

self::assertEquals('bar', $cookieFoo->getValue());
self::assertEquals('quux', $cookieQux->getValue());
self::assertSame('bar', $cookieFoo->getValue());
self::assertSame('quux', $cookieQux->getValue());
}
}
8 changes: 4 additions & 4 deletions tests/DomTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function testType(): void
->getReturnValue();

// checks if the input contains the typed text
self::assertEquals('bar', $value);
self::assertSame('bar', $value);
}

public function testGetText(): void
Expand All @@ -112,7 +112,7 @@ public function testGetText(): void

$value = $element->getText();

self::assertEquals('bar', $value);
self::assertSame('bar', $value);
}

public function testGetAttribute(): void
Expand All @@ -123,7 +123,7 @@ public function testGetAttribute(): void

$value = $element->getAttribute('type');

self::assertEquals('foo', $value);
self::assertSame('foo', $value);
}

public function testSetAttribute(): void
Expand All @@ -136,7 +136,7 @@ public function testSetAttribute(): void

$value = $element->getAttribute('type');

self::assertEquals('hello', $value);
self::assertSame('hello', $value);
}

public function testUploadFile(): void
Expand Down
6 changes: 3 additions & 3 deletions tests/KeyboardApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testTypeText(): void
->getReturnValue();

// checks if the input contains the typed text
self::assertEquals($text, $value);
self::assertSame($text, $value);
}

/**
Expand Down Expand Up @@ -127,7 +127,7 @@ public function testTypeKeyCombinations(): void
->getReturnValue();

// check if the input contains the typed text twice
self::assertEquals($text.$text, $value);
self::assertSame($text.$text, $value);
}

/**
Expand All @@ -144,7 +144,7 @@ public function testReleaseAll(): void
->press('b')
->release();

self::assertEquals(0, \count($page->keyboard()->getPressedKeys()));
self::assertCount(0, $page->keyboard()->getPressedKeys());
}

/**
Expand Down
24 changes: 12 additions & 12 deletions tests/KeyboardKeysTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@ public static function keyCodesProvider(): array
public function testOnKeyPressAndRelease($key, $expectedKey): void
{
self::assertFalse($this->keyboard->isKeyPressed());
self::assertEquals(0, $this->keyboard->getModifiers());
self::assertSame(0, $this->keyboard->getModifiers());

$this->keyboard->onKeyPress($key);

self::assertEquals($expectedKey, $this->keyboard->getCurrentKey());
self::assertEquals(0, $this->keyboard->getModifiers());
self::assertEquals(1, \count($this->keyboard->getPressedKeys()));
self::assertSame($expectedKey, $this->keyboard->getCurrentKey());
self::assertSame(0, $this->keyboard->getModifiers());
self::assertSame(1, \count($this->keyboard->getPressedKeys()));
self::assertTrue($this->keyboard->isKeyPressed());

$this->keyboard->onKeyRelease($key);

self::assertEquals($expectedKey, $this->keyboard->getCurrentKey());
self::assertEquals(0, \count($this->keyboard->getPressedKeys()));
self::assertEquals(0, $this->keyboard->getModifiers());
self::assertSame($expectedKey, $this->keyboard->getCurrentKey());
self::assertSame(0, \count($this->keyboard->getPressedKeys()));
self::assertSame(0, $this->keyboard->getModifiers());
self::assertFalse($this->keyboard->isKeyPressed());
}

Expand All @@ -96,23 +96,23 @@ public function testToggleModifierFromKey($key, $expectedModifier): void
$this->keyboard->setCurrentKey('NonModifierKey');
$this->keyboard->toggleModifierFromKey();

self::assertEquals($expectedModifier, $this->keyboard->getModifiers());
self::assertSame($expectedModifier, $this->keyboard->getModifiers());

$this->keyboard->setCurrentKey($key);
$this->keyboard->toggleModifierFromKey();
self::assertEquals(0, $this->keyboard->getModifiers());
self::assertSame(0, $this->keyboard->getModifiers());
}

public function testToggleModifier(): void
{
$this->keyboard->toggleModifier(0b0001);
$this->keyboard->toggleModifier(0b0010);

self::assertEquals(0b0011, $this->keyboard->getModifiers());
self::assertSame(0b0011, $this->keyboard->getModifiers());

$this->keyboard->toggleModifier(0b0010);

self::assertEquals(0b0001, $this->keyboard->getModifiers());
self::assertSame(0b0001, $this->keyboard->getModifiers());
}

/**
Expand All @@ -122,6 +122,6 @@ public function testGetKeyCode($key, $code): void
{
$this->keyboard->setCurrentKey($key);

self::assertEquals($code, $this->keyboard->getKeyCode());
self::assertSame($code, $this->keyboard->getKeyCode());
}
}
Loading

0 comments on commit d076f8d

Please sign in to comment.