codeception

How and where should I use the keyword “use” in php

我是研究僧i 提交于 2019-12-06 00:44:48
I used use the keyword "use" generally above the class definition. Like this: <?php namespace suites\plugins\content\agpaypal; use \Codeception\Util\Fixtures; use \Codeception\Verify; use \Codeception\Specify; class agpaypalTest extends \Codeception\Test\Unit { protected $tester; ... But now I realised, that I have to put the line for the trait Specify into the class definition. Like this: <?php namespace suites\plugins\content\agpaypal; use \Codeception\Util\Fixtures; use \Codeception\Verify; class agpaypalTest extends \Codeception\Test\Unit { use \Codeception\Specify; protected $tester; ...

How to change codeception phpbrowser/mink timeout

核能气质少年 提交于 2019-12-05 20:39:14
I'm trying to create test with codeception that will check's the page is properly working in case of high load. Unfortunately if the page is in very very high load and the tests starts I got such error: [..] [Codeception\Exception\ModuleConfig] Codeception\Util\Mink module is not configured! Provided URL can't be accessed by this driver.[curl] 28: Operation timed out after 30031 milliseconds with 0 out of -1 bytes received [url] http://xxxx.xxx/app_db2.php [..] Is there any possibility to set the Mink timeout to some higher value ? You can set curl options via your test suit configuration just

Codeception\Util\Stub methods ::exactly and ::once don't work

纵然是瞬间 提交于 2019-12-05 17:16:08
问题 I am using Codeception\Util\Stub to create unit tests. And I want to be sure that my method called several times. For this I am using method 'exactly'. Example: use \UnitTester; use \Codeception\Util\Stub as StubUtil; class someCest { public function testMyTest(UnitTester $I) { $stub = StubUtil::makeEmpty('myClass', [ 'myMethod' => StubUtil::exactly(2, function () { return 'returnValue'; }) ]); $stub->myMethod(); } } As you can see I called myMethod once. But test passed. The same problem

Authorization header not making it through in Codeception API testing

三世轮回 提交于 2019-12-05 03:10:35
I am attempting to test my Laravel 4 REST API using Codeception, but when I try to send through my Authorization header (using the $I->amBearerAuthenticated() function of the REST module) it is not making it through to the eventual request. From what I can see, the Symfony2 BrowserKit module modifies any headers added into the HTTP_XXX_XXX format, so the header being sent seems to be HTTP_AUTHORIZATION - when I output the received headers in my application, however, neither Authorization nor HTTP_AUTHORIZATION are present. If it helps, here is my Codeception test: public function

Select an option in a dynamic select with codeception?

旧巷老猫 提交于 2019-12-05 01:14:45
<select> <option value=''>-- Select an Option --</option> @foreach ($options as $option) <option value='{{ $option->value }}'>{{ $option->name }}</option> @endforeach </select> Select the first dynamic option $option = $I->grabTextFrom('select option:nth-child(2)'); $I->selectOption("select", $option); $I->click("Submit"); I've run into the same issue quite often when starting out with Codeception. Using the recommended answer, I created a helper function in my AcceptanceTester class to make this a little easier. public function selectFromDropdown($selector, $n) { $option = $this->grabTextFrom

Codeception & Symfony - run Doctrine migrations before tests

你。 提交于 2019-12-04 20:11:38
问题 I have a Symfony 4 application and Doctrine with Doctrine migrations. I'm introducing Codeception for running API tests, and need to run migrations before the tests run. Since I'm using the Doctrine2 module I don't really want to be also including the DB module as it's not needed for the tests and would require configuring the test database in two different locations. I am using the Symfony module currently, and I noticed that the Laravel module has a run_database_migrations configuration

for each element with behat or codeception

只愿长相守 提交于 2019-12-04 07:57:22
I want to test a website which has a dynamic menustructure. I want to loop through all menuitems and run the same series of test on every page. We're talking about 100+ pages that change reguraly. I would like to do this with either behat or codeception. Does anybody have an idea about how to do this? When using Behat with Mink, you can grab your menu items with findAll() and then iterate over it: /** * @When /^I run my test series for all menu items$/ */ public function iRunMyTestSeriesForAllMenuItems() { $result = TRUE; $this->getSession()->visit('http://www.example.com/'); $links = $this-

Run custom code after Codeception suite has finished

走远了吗. 提交于 2019-12-04 05:49:59
I am aware of the _bootstrap.php file that's used to set up the testing enviroment, etc., but I'm looking for a way to run some code after the entire test suite has finished. Note that I'm not looking for a way to run code after a single class, i.e. something like _after , but after all classes. Is there a way to achieve this? Actually managed to solve this myself, here's how, if anyone is interested. I created a new helper class inside _support. <?php class DataHelper extends \Codeception\Module { public function _beforeSuite() { // Set up before test suite } public function _afterSuite() { /

Is it possible to store Functional/Acceptance config URL of Codeception outside repository?

不羁岁月 提交于 2019-12-04 04:28:24
问题 I have a PHP project with Codeception on which several developers are working. Everyone have their own environment and different URL to their copy of the project. But in Codeception Functional/Acceptance yml config file we have to set up URL for acceptance and functional tests. How could we have different URL to project and have main part of configs in repository? Thank you in advance. 回答1: One way to solve this is to look at the $_SERVER['HOSTNAME'] value and select the appropriate url from

Codeception\\Util\\Stub methods ::exactly and ::once don't work

你。 提交于 2019-12-04 03:13:19
I am using Codeception\Util\Stub to create unit tests. And I want to be sure that my method called several times. For this I am using method 'exactly'. Example: use \UnitTester; use \Codeception\Util\Stub as StubUtil; class someCest { public function testMyTest(UnitTester $I) { $stub = StubUtil::makeEmpty('myClass', [ 'myMethod' => StubUtil::exactly(2, function () { return 'returnValue'; }) ]); $stub->myMethod(); } } As you can see I called myMethod once. But test passed. The same problem with method ::once , because this method is using the same class PHPUnit_Framework_MockObject_Matcher