GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Docs] Improved examples in ModulesAndHelpers · tmotyl/codeception.github.com@b6cd882

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • docs
    • 06-ModulesAndHelpers.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docs/06-ModulesAndHelpers.md‎

Copy file name to clipboardExpand all lines: docs/06-ModulesAndHelpers.md
+53-51Lines changed: 53 additions & 51 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ It's supposed to use the dbh connection value from the Db module.
237237

238238
<?php
239239
240-
function reconnectToDatabase() {
240+
function reconnectToDatabase()
241+
{
241242
$dbh = $this->getModule('Db')->dbh;
242243
$dbh->close();
243244
$dbh->open();
@@ -285,7 +286,8 @@ If accessing modules doesn't provide enough flexibility, you can extend a module
285286
<?php
286287
namespace Helper;
287288
288-
class MyExtendedSelenium extends \Codeception\Module\WebDriver {
289+
class MyExtendedSelenium extends \Codeception\Module\WebDriver
290+
{
289291
}
290292
291293
{% endhighlight %}
@@ -307,45 +309,45 @@ All hooks are defined in [Codeception\Module](http://codeception.com/docs/refere
307309
308310
<?php
309311
310-
// HOOK: used after configuration is loaded
311-
public function _initialize()
312-
{
313-
}
314-
315-
// HOOK: before each suite
316-
public function _beforeSuite($settings = array())
317-
{
318-
}
319-
320-
// HOOK: after suite
321-
public function _afterSuite()
322-
{
323-
}
324-
325-
// HOOK: before each step
326-
public function _beforeStep(\Codeception\Step $step)
327-
{
328-
}
329-
330-
// HOOK: after each step
331-
public function _afterStep(\Codeception\Step $step)
332-
{
333-
}
334-
335-
// HOOK: before test
336-
public function _before(\Codeception\TestInterface $test)
337-
{
338-
}
339-
340-
// HOOK: after test
341-
public function _after(\Codeception\TestInterface $test)
342-
{
343-
}
344-
345-
// HOOK: on fail
346-
public function _failed(\Codeception\TestInterface $test, $fail)
347-
{
348-
}
312+
// HOOK: used after configuration is loaded
313+
public function _initialize()
314+
{
315+
}
316+
317+
// HOOK: before each suite
318+
public function _beforeSuite($settings = array())
319+
{
320+
}
321+
322+
// HOOK: after suite
323+
public function _afterSuite()
324+
{
325+
}
326+
327+
// HOOK: before each step
328+
public function _beforeStep(\Codeception\Step $step)
329+
{
330+
}
331+
332+
// HOOK: after each step
333+
public function _afterStep(\Codeception\Step $step)
334+
{
335+
}
336+
337+
// HOOK: before test
338+
public function _before(\Codeception\TestInterface $test)
339+
{
340+
}
341+
342+
// HOOK: after test
343+
public function _after(\Codeception\TestInterface $test)
344+
{
345+
}
346+
347+
// HOOK: on fail
348+
public function _failed(\Codeception\TestInterface $test, $fail)
349+
{
350+
}
349351
350352
{% endhighlight %}
351353
@@ -368,9 +370,9 @@ Here is an example of how it works for PhpBrowser:
368370
{% highlight php %}
369371
370372
<?php
371-
$this->debugSection('Request', $params);
372-
$this->client->request($method, $uri, $params);
373-
$this->debug('Response Code: ' . $this->client->getStatusCode());
373+
$this->debugSection('Request', $params);
374+
$this->client->request($method, $uri, $params);
375+
$this->debug('Response Code: ' . $this->client->getStatusCode());
374376

375377
{% endhighlight %}
376378

@@ -492,19 +494,19 @@ and `SAUCE_KEY` variables from environment, and now we are passing their values
492494

493495
{% highlight yaml %}
494496

495-
modules:
496-
enabled:
497-
- WebDriver:
498-
url: http://mysite.com
499-
host: '%SAUCE_USER%:%SAUCE_KEY%@ondemand.saucelabs.com'
497+
modules:
498+
enabled:
499+
- WebDriver:
500+
url: http://mysite.com
501+
host: '%SAUCE_USER%:%SAUCE_KEY%@ondemand.saucelabs.com'
500502

501503
{% endhighlight %}
502504

503505
Parameters are also useful to provide connection credentials for the `Db` module (taken from Laravel's .env files):
504506

505507
{% highlight yaml %}
506508

507-
module:
509+
modules:
508510
enabled:
509511
- Db:
510512
dsn: "mysql:host=%DB_HOST%;dbname=%DB_DATABASE%"
@@ -588,4 +590,4 @@ Helpers also can be used to extend the functionality of the original modules.
588590

589591

590592
* **Next Chapter: [ReusingTestCode >](/docs/06-ReusingTestCode)**
591-
* **Previous Chapter: [< UnitTests](/docs/05-UnitTests)**
593+
* **Previous Chapter: [< UnitTests](/docs/05-UnitTests)**

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.