Skip to content

Commit 07649c8

Browse files
committed
docs page added
1 parent a45dbfc commit 07649c8

6 files changed

Lines changed: 292 additions & 1 deletion

File tree

‎_layouts/default.html‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@
3333
<div class="nav">
3434
<a href="/" ><img src="/images/logo.png" alt="Codeception"></a>
3535
<ul>
36+
<li><a href="/docs">Docs</a></li>
3637
<li><a href="/blog">Blog</a>
3738
<li><a href="/qa">Q&A</a>
3839
<li><a href="/credits">Credits</a>
39-
<li><a class="active" href="/install">GET IT NOW!</a>
40+
<li><a class="active" href="/install">INSTALL</a>
4041
</li></ul>
4142
</div>
4243

‎css/screen.css‎

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs.markdown‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
layout: page
3+
title: Codeception Documentation
4+
---
5+
6+
# Documentation
7+
8+
## Guides
9+
10+
Guides will walk you though the basic concepts of testing to the full understanding knowlegde of Codeception.
11+
Everything you want to know about Codeception can be found in Guides.
12+
13+
* [Intruduction](/docs/01-Introduction) - all about testing: acceptance, unit, and functional tests explained.
14+
* [Getting Started](/docs/02-GettingStarted) - setting up and writing a first test with Codeception
15+
* [Modules](/docs/03-Modules) - understanding modules and helpers
16+
* [Acceptance Tests](/docs/04-AcceptanceTests) - writing Selenium and PhpBrowser accetance tests.
17+
* [Functional Tests](/docs/05-FunctionalTests) - writing functional tests for popular PHP frameworks.
18+
* [Unit Tests in Scenarios](/docs/06-UnitTestsScenarios) - unit testing in scenarios proof of concept.
19+
* [Unit Tests Practice](/docs/07-UnitTestsPractice) - practical approach to unit testing in scenario manner.
20+
* [Data](/docs/08-Data) - repopulation of database, cleaning up data, using fixtures, etc.
21+
22+
## References
23+
24+
References explains API of verious parts of Codeception. Look for them if you forgot something.
25+
26+
* [Commands](/docs/reference/commands) - explains usage of Codecption console utility.
27+
* Configuration - explains basics of suites configuration.
28+
* [Xml Builder](/docs/reference/xmlbuilder) - building XMLs pragmatically.
29+
* [Stubs](/docs/reference/stubs) - cool stub builder explained.
30+
31+
## Modules
32+
33+
Modules are used to test various parts of your application. There are plenty of those and many should arrive in a future.
34+
Choose the best module for your needs and see it's reference.
35+
36+
### Testing Web Applications with Javascript
37+
38+
* [Selenium](/docs/modules/Selenium) - use Selenium server to run tests in browser.
39+
* [Selenium2](/docs/modules/Selenium2) - use Selenium server to run tests in browser.
40+
* [ZombieJS](/docs/modules/ZombieJS) - use Zombie.js backend to run tests without browser.
41+
42+
### Testing Web Applications without Javascript
43+
44+
* [PhpBrowser](/docs/modules/PhpBrowser) - emulates browser usage by fetching and parsing html pages.
45+
46+
### Testing Inside PHP Frameworks
47+
48+
* [Symfony2](/docs/modules/Symfony2) - wraper for [Symfony2](http://symfony.com) functional tests.
49+
* [Zend Framework](/docs/modules/Zend) - wraper for [ZF](http://framework.zend.com) functional test.
50+
* [symfony](/docs/modules/symfony) - wraper for [symfony 1.x](http://symfony-project.org) functional test
51+
* [Kohana](/docs/modules/Kohana)
52+
* [Social Engine](/docs/module/SocialEngine) - ZF module adopted for SE
53+
54+
### Unit Testing
55+
56+
Basically you could use PHPUnit tests for unit testing. But Codeception scenario-driven unit tests are much powerful )
57+
58+
* [Unit](/docs/modules/unit) - everything for unit testing.
59+
60+
### API Testing
61+
62+
* [REST](/docs/modules/REST) - testing REST Web services (can be tested inside framework)
63+
* [SOAP](/docs/modules/SOAP) - testing SOAP WSDL web-services (can be tested inside framework)
64+
65+
### Database Testing
66+
67+
* [Db](/docs/modules/Db) - use to test changes in database
68+
* [Doctrine2](/docs/modules/doctrine2) - test database managed by [Doctrine2](http://www.doctrine-project.org/) ORM
69+
* [Doctrine](docs/modules/doctrine) - test database managed by [Doctrine](http://www.doctrine-project.org/) 1.x ORM
70+

‎docs/reference/commands.markdown‎

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
layout: page
3+
title: Codeception Commands
4+
---
5+
6+
# Commands
7+
8+
Depending on version run Codeception console uitility in following way:
9+
10+
* `php codecept.phar run` - for downloaded phar executable.
11+
* `codecept run` - for PEAR installation
12+
* `php vendor/bin/codecept` - for composer installation.
13+
14+
The commands listed below use PEAR installation as an example.
15+
16+
## Run
17+
18+
Executes Tests.
19+
20+
### Usage
21+
22+
* `codecept run` - executes all tests in all suites
23+
* `codecept run suitename` - executes all test from this suite
24+
* `codecept run suitename testnameTest.php` - executes one test of this suite (provide local path for suite directory).
25+
26+
### Options
27+
28+
* `--debug` - additional debug output will be printed.
29+
* `--steps` - all performed actions will be printed to console.
30+
* `--colors` - turn on colors (if disabled)
31+
* `--silent` - don't show the progress output.
32+
* `--report` - format results in report mode.
33+
* `--no-exit` - don't provide exit codes on finish. This option may be useful for using Codeception with some CI servers like Bamboo.
34+
* `--html` - generate html file with results. It will be stored as 'report.html' in tests/_log.
35+
* `--xml` - generate report in JUnit format for CI services. It will be stored as 'report.xml' in tests/_log.
36+
* `--tap` - generate report in TAP format. It will be stored as 'report.tap.log' in tests/_log.
37+
* `--json` - generate report in Json format. It will be stored as 'report.json' in tests/_log.
38+
39+
## Boostrap
40+
41+
Creates default config, tests directory and sample suites for current project.
42+
Use this command to start building a test suite.
43+
44+
### Usage
45+
46+
* `codecept bootstrap`
47+
48+
## Install
49+
50+
Tries to install Mink, PHPUnit, Symfony Components via PEAR. This command needs to successfully complete PEAR installation. This command may fail due to PEAR issues. We recommend to use phar executable or Composer, if you don't have time and enthusiasm to fight PEAR bugs.
51+
52+
### Usage
53+
54+
* `codecept install`
55+
56+
## Generate Suite
57+
58+
Generates a new empty suite. You may generate new suite for integration tests, for testing different part of appications, etc.
59+
60+
### Usage
61+
62+
* `codecept genrate:suite suitename guyname` - provide name of suite and name a Guy who will be used in tests.
63+
64+
Don't create two guys with the same name!
65+
66+
## Generate Cept
67+
68+
Generates new empty test file for acceptance and functional tests. Scenario-based test is called Cept, though.
69+
70+
### Usage
71+
72+
* `codcept generate:cept suitename testname` - generates testnameCept.php inside the suite.
73+
* `codecept generate:cept suitename subdir/subdir/testnameCept.php` - generates file in subdir/subdir of suite dir.
74+
75+
## Generate Cest
76+
77+
Generates new empty test file for scenario-based unit tests. This file format is called Cest = Cept + Test.
78+
79+
### Usage
80+
81+
* `codcept generate:cest suitename testname` - generates testnameCest.php inside the suite.
82+
* `codecept generate:cest suitename subdir/subdir/testnameCest.php` - generates file in subdir/subdir of suite dir.
83+
84+
## Generate Scenarios
85+
86+
Generates text representation for all tests in suite. They are called scenarios and stored as a text files in the `log` dir.
87+
88+
### Usage
89+
90+
* `codecept generate:scenarios suitename` - generates for this suite.
91+
92+
93+

‎docs/reference/stubs.markdown‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
layout: page
3+
title: Codeception Stubs
4+
---
5+
6+
# Stub
7+
8+
Class for easily create stubs in your unit tests. You can use this class even inside PHPUnit tests too. It's a useful wrapper on top of PHPUnit mock builder.
9+
10+
### Usage
11+
12+
* `make` - creates new class bypassing constructor
13+
* `makeEmpty` - creates new class bypassing constructor with all methods return null.
14+
* `construct` - creates new class throgh constructor.
15+
* `constructEmpty` - creates new empty class throgh constructor with all methods return null.
16+
* `copy` - copies object and redefines it's properties.
17+
18+
### Example
19+
20+
{% highlight php %}
21+
use \Codeception\Util\Stub as Stub;
22+
23+
// create class instance with name set method 'save' redefined.
24+
$user = Stub::make('User', array('name' => 'davert', 'save' => function () { return true; }));
25+
26+
// create class instance with all empty methods (will return NULL)
27+
$user = Stub::makeEmpty('User', array('getName' => function () { return 'davert'; }));
28+
$user->save(); // is empty and returns NULL
29+
$user->getName(); // return 'davert'
30+
31+
// create class with empty methods except one
32+
$user = Stub::makeEmptyExcept('User', 'getName', array('name' => 'davert'));
33+
$user->save(); // is empty and returns NULL
34+
$user->getName(); // returns 'davert'
35+
36+
// create class instance through constructor
37+
// second parameter is array, it's values will be passed to constructor.
38+
39+
// similar to $user = new User($con, $is_new);
40+
$user = Stub::construct('User', array($con, $is_new), array('name' => 'davert'));
41+
42+
// similar is constructEmpty
43+
$user = Stub::constructEmpty('User', array($con, $is_new), array('getName' => function () { return 'davert'; }));
44+
45+
// and constructEmptyExcept
46+
$user = Stub::constructEmptyExcept('User', 'getName', array($con, $is_new), array('name' => 'davert'));
47+
48+
// copy and redefine class instance
49+
// can act with regular objects, not only stubs
50+
$user->getName(); // returns 'davert'
51+
$user2 = Stub::copy($user, array('name' => 'davert2'));
52+
$user->getName(); // returns 'davert2'
53+
{% endhighlight %}
54+

‎docs/reference/xmlbuilder.markdown‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
layout: page
3+
title: Codeception Xml Builder
4+
---
5+
6+
# Xml Builder
7+
8+
That's a pretty simple yet powerful class to build XML structures in jQuery-like style. With no XML line actually written!
9+
Uses DOM extension to manipulate XML data.
10+
11+
{% highlight php %}
12+
<?php
13+
14+
$xml = new \Codeception\Util\XmlBuilder();
15+
$xml->users
16+
->user
17+
->val(1)
18+
->email
19+
->val('davert@mail.ua')
20+
->attr('valid','true')
21+
->parent()
22+
->cart
23+
->attr('empty','false')
24+
->items
25+
->item
26+
->val('useful item');
27+
->parents('user')
28+
->active
29+
->val(1);
30+
echo $xml;
31+
{% endhighlight %}
32+
33+
This will produce this XML
34+
35+
{% highlight xml %}
36+
37+
<?xml version="1.0"?>
38+
<users>
39+
<user>
40+
1
41+
<email valid="true">davert@mail.ua</email>
42+
<cart empty="false">
43+
<items>
44+
<item>useful item</item>
45+
</items>
46+
</cart>
47+
<active>1</active>
48+
</user>
49+
</users>
50+
{% endhighlight %}
51+
52+
Easy, right?
53+
54+
### Usage
55+
56+
Builder uses chained calls. So each call to builder returns a builder object. Except for `getDom` and `__toString` methods.
57+
58+
* `$xml->node` - create new xml node and go inside of it.
59+
* `$xml->node->val('value')` - sets the inner value of node
60+
* `$xml->attr('name','value')` - set the attribute of node
61+
* `$xml->parent()` - go back to parent node.
62+
* `$xml->parents('user')` - go back through all parents to `user` node.
63+
64+
Export:
65+
66+
* `$xml->getDom` - get a DOMDocument object
67+
* `$xml->__toString` - get a string representation of XML.
68+
69+
[Source code](https://github.com/Codeception/Codeception/blob/master/src/Codeception/Util/XmlBuilder.php)

0 commit comments

Comments
 (0)