init
This commit is contained in:
73
vendor/codeception/base/tests/unit/Codeception/Constraints/CrawlerConstraintTest.php
vendored
Normal file
73
vendor/codeception/base/tests/unit/Codeception/Constraints/CrawlerConstraintTest.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
class CrawlerConstraintTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Codeception\PHPUnit\Constraint\Crawler
|
||||
*/
|
||||
protected $constraint;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->constraint = new Codeception\PHPUnit\Constraint\Crawler('hello', '/user');
|
||||
}
|
||||
|
||||
public function testEvaluation()
|
||||
{
|
||||
$nodes = new Symfony\Component\DomCrawler\Crawler("<p>Bye world</p><p>Hello world</p>");
|
||||
$this->constraint->evaluate($nodes);
|
||||
}
|
||||
|
||||
public function testFailMessageResponse()
|
||||
{
|
||||
$nodes = new Symfony\Component\DomCrawler\Crawler('<p>Bye world</p><p>Bye warcraft</p>');
|
||||
try {
|
||||
$this->constraint->evaluate($nodes->filter('p'), 'selector');
|
||||
} catch (\PHPUnit\Framework\AssertionFailedError $fail) {
|
||||
$this->assertContains(
|
||||
"Failed asserting that any element by 'selector' on page /user",
|
||||
$fail->getMessage()
|
||||
);
|
||||
$this->assertContains('+ <p>Bye world</p>', $fail->getMessage());
|
||||
$this->assertContains('+ <p>Bye warcraft</p>', $fail->getMessage());
|
||||
return;
|
||||
}
|
||||
$this->fail("should have failed, but not");
|
||||
}
|
||||
|
||||
public function testFailMessageResponseWhenMoreNodes()
|
||||
{
|
||||
$html = '';
|
||||
for ($i = 0; $i < 15; $i++) {
|
||||
$html .= "<p>item $i</p>";
|
||||
}
|
||||
$nodes = new Symfony\Component\DomCrawler\Crawler($html);
|
||||
try {
|
||||
$this->constraint->evaluate($nodes->filter('p'), 'selector');
|
||||
} catch (\PHPUnit\Framework\AssertionFailedError $fail) {
|
||||
$this->assertContains(
|
||||
"Failed asserting that any element by 'selector' on page /user",
|
||||
$fail->getMessage()
|
||||
);
|
||||
$this->assertNotContains('+ <p>item 0</p>', $fail->getMessage());
|
||||
$this->assertNotContains('+ <p>item 14</p>', $fail->getMessage());
|
||||
$this->assertContains('[total 15 elements]', $fail->getMessage());
|
||||
return;
|
||||
}
|
||||
$this->fail("should have failed, but not");
|
||||
}
|
||||
|
||||
public function testFailMessageResponseWithoutUrl()
|
||||
{
|
||||
$this->constraint = new Codeception\PHPUnit\Constraint\Crawler('hello');
|
||||
$nodes = new Symfony\Component\DomCrawler\Crawler('<p>Bye world</p><p>Bye warcraft</p>');
|
||||
try {
|
||||
$this->constraint->evaluate($nodes->filter('p'), 'selector');
|
||||
} catch (\PHPUnit\Framework\AssertionFailedError $fail) {
|
||||
$this->assertContains("Failed asserting that any element by 'selector'", $fail->getMessage());
|
||||
$this->assertNotContains("Failed asserting that any element by 'selector' on page", $fail->getMessage());
|
||||
return;
|
||||
}
|
||||
$this->fail("should have failed, but not");
|
||||
}
|
||||
}
|
||||
66
vendor/codeception/base/tests/unit/Codeception/Constraints/CrawlerNotConstraintTest.php
vendored
Normal file
66
vendor/codeception/base/tests/unit/Codeception/Constraints/CrawlerNotConstraintTest.php
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
class CrawlerNotConstraintTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Codeception\PHPUnit\Constraint\Crawler
|
||||
*/
|
||||
protected $constraint;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->constraint = new Codeception\PHPUnit\Constraint\CrawlerNot('warcraft', '/user');
|
||||
}
|
||||
|
||||
public function testEvaluation()
|
||||
{
|
||||
$nodes = new Symfony\Component\DomCrawler\Crawler("<p>Bye world</p><p>Hello world</p>");
|
||||
$this->constraint->evaluate($nodes);
|
||||
}
|
||||
|
||||
public function testFailMessageResponse()
|
||||
{
|
||||
$nodes = new Symfony\Component\DomCrawler\Crawler('<p>Bye world</p><p>Bye warcraft</p>');
|
||||
try {
|
||||
$this->constraint->evaluate($nodes->filter('p'), 'selector');
|
||||
} catch (\PHPUnit\Framework\AssertionFailedError $fail) {
|
||||
$this->assertContains("There was 'selector' element on page /user", $fail->getMessage());
|
||||
$this->assertNotContains('+ <p>Bye world</p>', $fail->getMessage());
|
||||
$this->assertContains('+ <p>Bye warcraft</p>', $fail->getMessage());
|
||||
return;
|
||||
}
|
||||
$this->fail("should have failed, but not");
|
||||
}
|
||||
|
||||
public function testFailMessageResponseWhenMoreNodes()
|
||||
{
|
||||
$html = '';
|
||||
for ($i = 0; $i < 15; $i++) {
|
||||
$html .= "<p>warcraft $i</p>";
|
||||
}
|
||||
$nodes = new Symfony\Component\DomCrawler\Crawler($html);
|
||||
try {
|
||||
$this->constraint->evaluate($nodes->filter('p'), 'selector');
|
||||
} catch (\PHPUnit\Framework\AssertionFailedError $fail) {
|
||||
$this->assertContains("There was 'selector' element on page /user", $fail->getMessage());
|
||||
$this->assertContains('+ <p>warcraft 0</p>', $fail->getMessage());
|
||||
$this->assertContains('+ <p>warcraft 14</p>', $fail->getMessage());
|
||||
return;
|
||||
}
|
||||
$this->fail("should have failed, but not");
|
||||
}
|
||||
|
||||
public function testFailMessageResponseWithoutUrl()
|
||||
{
|
||||
$this->constraint = new Codeception\PHPUnit\Constraint\CrawlerNot('warcraft');
|
||||
$nodes = new Symfony\Component\DomCrawler\Crawler('<p>Bye world</p><p>Bye warcraft</p>');
|
||||
try {
|
||||
$this->constraint->evaluate($nodes->filter('p'), 'selector');
|
||||
} catch (\PHPUnit\Framework\AssertionFailedError $fail) {
|
||||
$this->assertContains("There was 'selector' element", $fail->getMessage());
|
||||
$this->assertNotContains("There was 'selector' element on page /user", $fail->getMessage());
|
||||
return;
|
||||
}
|
||||
$this->fail("should have failed, but not");
|
||||
}
|
||||
}
|
||||
90
vendor/codeception/base/tests/unit/Codeception/Constraints/WebDriverConstraintTest.php
vendored
Normal file
90
vendor/codeception/base/tests/unit/Codeception/Constraints/WebDriverConstraintTest.php
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
require_once __DIR__.'/mocked_webelement.php';
|
||||
|
||||
class WebDriverConstraintTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Codeception\PHPUnit\Constraint\WebDriver
|
||||
*/
|
||||
protected $constraint;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->constraint = new Codeception\PHPUnit\Constraint\WebDriver('hello', '/user');
|
||||
}
|
||||
|
||||
public function testEvaluation()
|
||||
{
|
||||
$nodes = array(new TestedWebElement('Hello world'), new TestedWebElement('Bye world'));
|
||||
$this->constraint->evaluate($nodes);
|
||||
}
|
||||
|
||||
public function testFailMessageResponseWithStringSelector()
|
||||
{
|
||||
$nodes = array(new TestedWebElement('Bye warcraft'), new TestedWebElement('Bye world'));
|
||||
try {
|
||||
$this->constraint->evaluate($nodes, 'selector');
|
||||
} catch (\PHPUnit\Framework\AssertionFailedError $fail) {
|
||||
$this->assertContains(
|
||||
"Failed asserting that any element by 'selector' on page /user",
|
||||
$fail->getMessage()
|
||||
);
|
||||
$this->assertContains('+ <p> Bye world', $fail->getMessage());
|
||||
$this->assertContains('+ <p> Bye warcraft', $fail->getMessage());
|
||||
return;
|
||||
}
|
||||
$this->fail("should have failed, but not");
|
||||
}
|
||||
|
||||
public function testFailMessageResponseWithArraySelector()
|
||||
{
|
||||
$nodes = array(new TestedWebElement('Bye warcraft'));
|
||||
try {
|
||||
$this->constraint->evaluate($nodes, ['css' => 'p.mocked']);
|
||||
} catch (\PHPUnit\Framework\AssertionFailedError $fail) {
|
||||
$this->assertContains(
|
||||
"Failed asserting that any element by css 'p.mocked' on page /user",
|
||||
$fail->getMessage()
|
||||
);
|
||||
$this->assertContains('+ <p> Bye warcraft', $fail->getMessage());
|
||||
return;
|
||||
}
|
||||
$this->fail("should have failed, but not");
|
||||
}
|
||||
|
||||
public function testFailMessageResponseWhenMoreNodes()
|
||||
{
|
||||
$nodes = array();
|
||||
for ($i = 0; $i < 15; $i++) {
|
||||
$nodes[] = new TestedWebElement("item $i");
|
||||
}
|
||||
try {
|
||||
$this->constraint->evaluate($nodes, 'selector');
|
||||
} catch (\PHPUnit\Framework\AssertionFailedError $fail) {
|
||||
$this->assertContains(
|
||||
"Failed asserting that any element by 'selector' on page /user",
|
||||
$fail->getMessage()
|
||||
);
|
||||
$this->assertNotContains('+ <p> item 0', $fail->getMessage());
|
||||
$this->assertNotContains('+ <p> item 14', $fail->getMessage());
|
||||
$this->assertContains('[total 15 elements]', $fail->getMessage());
|
||||
return;
|
||||
}
|
||||
$this->fail("should have failed, but not");
|
||||
}
|
||||
|
||||
public function testFailMessageResponseWithoutUrl()
|
||||
{
|
||||
$this->constraint = new Codeception\PHPUnit\Constraint\WebDriver('hello');
|
||||
$nodes = array(new TestedWebElement('Bye warcraft'), new TestedWebElement('Bye world'));
|
||||
try {
|
||||
$this->constraint->evaluate($nodes, 'selector');
|
||||
} catch (\PHPUnit\Framework\AssertionFailedError $fail) {
|
||||
$this->assertContains("Failed asserting that any element by 'selector'", $fail->getMessage());
|
||||
$this->assertNotContains("Failed asserting that any element by 'selector' on page", $fail->getMessage());
|
||||
return;
|
||||
}
|
||||
$this->fail("should have failed, but not");
|
||||
}
|
||||
}
|
||||
80
vendor/codeception/base/tests/unit/Codeception/Constraints/WebDriverNotConstraintTest.php
vendored
Normal file
80
vendor/codeception/base/tests/unit/Codeception/Constraints/WebDriverNotConstraintTest.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
require_once __DIR__.'/mocked_webelement.php';
|
||||
|
||||
class WebDriverConstraintNotTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Codeception\PHPUnit\Constraint\WebDriver
|
||||
*/
|
||||
protected $constraint;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->constraint = new Codeception\PHPUnit\Constraint\WebDriverNot('warcraft', '/user');
|
||||
}
|
||||
|
||||
public function testEvaluation()
|
||||
{
|
||||
$nodes = array(new TestedWebElement('Hello world'), new TestedWebElement('Bye world'));
|
||||
$this->constraint->evaluate($nodes);
|
||||
}
|
||||
|
||||
public function testFailMessageResponseWithStringSelector()
|
||||
{
|
||||
$nodes = array(new TestedWebElement('Bye warcraft'), new TestedWebElement('Bye world'));
|
||||
try {
|
||||
$this->constraint->evaluate($nodes, 'selector');
|
||||
} catch (\PHPUnit\Framework\AssertionFailedError $fail) {
|
||||
$this->assertContains("There was 'selector' element on page /user", $fail->getMessage());
|
||||
$this->assertNotContains('+ <p> Bye world', $fail->getMessage());
|
||||
$this->assertContains('+ <p> Bye warcraft', $fail->getMessage());
|
||||
return;
|
||||
}
|
||||
$this->fail("should have failed, but not");
|
||||
}
|
||||
|
||||
public function testFailMessageResponseWithArraySelector()
|
||||
{
|
||||
$nodes = array(new TestedWebElement('Bye warcraft'));
|
||||
try {
|
||||
$this->constraint->evaluate($nodes, ['css' => 'p.mocked']);
|
||||
} catch (\PHPUnit\Framework\AssertionFailedError $fail) {
|
||||
$this->assertContains("There was css 'p.mocked' element on page /user", $fail->getMessage());
|
||||
$this->assertContains('+ <p> Bye warcraft', $fail->getMessage());
|
||||
return;
|
||||
}
|
||||
$this->fail("should have failed, but not");
|
||||
}
|
||||
|
||||
public function testFailMessageResponseWhenMoreNodes()
|
||||
{
|
||||
$nodes = array();
|
||||
for ($i = 0; $i < 15; $i++) {
|
||||
$nodes[] = new TestedWebElement("warcraft $i");
|
||||
}
|
||||
try {
|
||||
$this->constraint->evaluate($nodes, 'selector');
|
||||
} catch (\PHPUnit\Framework\AssertionFailedError $fail) {
|
||||
$this->assertContains("There was 'selector' element on page /user", $fail->getMessage());
|
||||
$this->assertContains('+ <p> warcraft 0', $fail->getMessage());
|
||||
$this->assertContains('+ <p> warcraft 14', $fail->getMessage());
|
||||
return;
|
||||
}
|
||||
$this->fail("should have failed, but not");
|
||||
}
|
||||
|
||||
public function testFailMessageResponseWithoutUrl()
|
||||
{
|
||||
$this->constraint = new Codeception\PHPUnit\Constraint\WebDriverNot('warcraft');
|
||||
$nodes = array(new TestedWebElement('Bye warcraft'), new TestedWebElement('Bye world'));
|
||||
try {
|
||||
$this->constraint->evaluate($nodes, 'selector');
|
||||
} catch (\PHPUnit\Framework\AssertionFailedError $fail) {
|
||||
$this->assertContains("There was 'selector' element", $fail->getMessage());
|
||||
$this->assertNotContains("There was 'selector' element on page", $fail->getMessage());
|
||||
return;
|
||||
}
|
||||
$this->fail("should have failed, but not");
|
||||
}
|
||||
}
|
||||
25
vendor/codeception/base/tests/unit/Codeception/Constraints/mocked_webelement.php
vendored
Normal file
25
vendor/codeception/base/tests/unit/Codeception/Constraints/mocked_webelement.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
class TestedWebElement extends RemoteWebElement
|
||||
{
|
||||
|
||||
protected $value;
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getTagName()
|
||||
{
|
||||
return 'p';
|
||||
}
|
||||
public function getText()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function isDisplayed()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user