-
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.
Convert unittests to PHP 8 attributes
- Loading branch information
Showing
9 changed files
with
59 additions
and
55 deletions.
There are no files selected for viewing
35 changes: 18 additions & 17 deletions
35
src/test/php/unittest/web/tests/AssertionMethodsTest.class.php
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 |
---|---|---|
@@ -1,113 +1,114 @@ | ||
<?php namespace unittest\web\tests; | ||
|
||
use peer\http\HttpConstants; | ||
use peer\URL; | ||
use peer\http\HttpConstants; | ||
use text\regex\Pattern; | ||
use unittest\Test; | ||
|
||
class AssertionMethodsTest extends WebTestCaseTest { | ||
|
||
#[@test] | ||
#[Test] | ||
public function assertStatus() { | ||
$this->fixture->respondWith(HttpConstants::STATUS_OK, [], ''); | ||
$this->fixture->beginAt('/'); | ||
$this->fixture->assertStatus(HttpConstants::STATUS_OK); | ||
} | ||
|
||
#[@test] | ||
#[Test] | ||
public function assertStatusIn() { | ||
$this->fixture->respondWith(HttpConstants::STATUS_OK, [], ''); | ||
$this->fixture->beginAt('/'); | ||
$this->fixture->assertStatusIn([HttpConstants::STATUS_OK]); | ||
} | ||
|
||
#[@test] | ||
#[Test] | ||
public function assertUrlEquals() { | ||
$this->fixture->respondWith(HttpConstants::STATUS_OK, [], ''); | ||
$this->fixture->beginAt('/'); | ||
$this->fixture->assertUrlEquals(new URL('http://localhost/')); | ||
} | ||
|
||
#[@test] | ||
#[Test] | ||
public function assertContentType() { | ||
$this->fixture->respondWith(HttpConstants::STATUS_OK, ['Content-Type: text/plain'], ''); | ||
$this->fixture->beginAt('/'); | ||
$this->fixture->assertContentType('text/plain'); | ||
} | ||
|
||
#[@test] | ||
#[Test] | ||
public function assertContentType_with_charset() { | ||
$this->fixture->respondWith(HttpConstants::STATUS_OK, ['Content-Type: text/xml; charset=utf-8']); | ||
$this->fixture->beginAt('/'); | ||
$this->fixture->assertContentType('text/xml; charset=utf-8'); | ||
} | ||
|
||
#[@test] | ||
#[Test] | ||
public function assertHeader() { | ||
$this->fixture->respondWith(HttpConstants::STATUS_OK, ['ETag: "214ceb4b-980-3a7bbd9630480"'], ''); | ||
$this->fixture->beginAt('/'); | ||
$this->fixture->assertHeader('ETag', '"214ceb4b-980-3a7bbd9630480"'); | ||
} | ||
|
||
#[@test] | ||
#[Test] | ||
public function assertElementPresent() { | ||
$this->fixture->respondWith(HttpConstants::STATUS_OK, [], '<html><body><div id="content"/></html>'); | ||
$this->fixture->beginAt('/'); | ||
$this->fixture->assertElementPresent('content'); | ||
} | ||
|
||
#[@test] | ||
#[Test] | ||
public function assertTextPresent() { | ||
$this->fixture->respondWith(HttpConstants::STATUS_OK, [], '<html><body>Content</html>'); | ||
$this->fixture->beginAt('/'); | ||
$this->fixture->assertTextPresent('Content'); | ||
} | ||
|
||
#[@test] | ||
#[Test] | ||
public function assertTextPatternPresent() { | ||
$this->fixture->respondWith(HttpConstants::STATUS_OK, [], '<html><body>Content</html>'); | ||
$this->fixture->beginAt('/'); | ||
$this->fixture->assertTextPatternPresent(new Pattern('content', Pattern::CASE_INSENSITIVE)); | ||
} | ||
|
||
#[@test] | ||
#[Test] | ||
public function assertImagePresent() { | ||
$this->fixture->respondWith(HttpConstants::STATUS_OK, [], '<html><body><img src="blank.gif"/></html>'); | ||
$this->fixture->beginAt('/'); | ||
$this->fixture->assertImagePresent('blank.gif'); | ||
} | ||
|
||
#[@test] | ||
#[Test] | ||
public function assertLinkPresent() { | ||
$this->fixture->respondWith(HttpConstants::STATUS_OK, [], '<html><body><a href="http://example.com/">.</a></html>'); | ||
$this->fixture->beginAt('/'); | ||
$this->fixture->assertLinkPresent('http://example.com/'); | ||
} | ||
|
||
#[@test] | ||
#[Test] | ||
public function assertLinkPresentWithText() { | ||
$this->fixture->respondWith(HttpConstants::STATUS_OK, [], '<html><body><a href="http://example.com/">Example</a></html>'); | ||
$this->fixture->beginAt('/'); | ||
$this->fixture->assertLinkPresentWithText('Example'); | ||
} | ||
|
||
#[@test] | ||
#[Test] | ||
public function assertFormPresent_without_name() { | ||
$this->fixture->respondWith(HttpConstants::STATUS_OK, [], '<html><body><form></form></html>'); | ||
$this->fixture->beginAt('/'); | ||
$this->fixture->assertFormPresent(); | ||
} | ||
|
||
#[@test] | ||
#[Test] | ||
public function assertFormPresent_with_name() { | ||
$this->fixture->respondWith(HttpConstants::STATUS_OK, [], '<html><body><form name="login"></form></html>'); | ||
$this->fixture->beginAt('/'); | ||
$this->fixture->assertFormPresent('login'); | ||
} | ||
|
||
#[@test] | ||
#[Test] | ||
public function assertTitleEquals() { | ||
$this->fixture->respondWith(HttpConstants::STATUS_OK, [], '<html><head><title>Test</title></head><body/></html>'); | ||
$this->fixture->beginAt('/'); | ||
$this->fixture->assertTitleEquals('Test'); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.