Skip to content

Commit 9a19f31

Browse files
authored
Merge pull request Codeception#665 from Codeception/redirect-to-new-pages
Replace old guide pages with redirects to new pages
2 parents 0aea212 + 64e008e commit 9a19f31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+7132
-6346
lines changed

RoboFile.php

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,38 +69,51 @@ public function buildDocsGuides() {
6969
->sortByName()
7070
->in('guides');
7171

72-
$prevVersionDocs = [
73-
'01-Introduction.md', '02-GettingStarted.md', '03-AcceptanceTests.md', '04-FunctionalTests.md', '05-UnitTests.md', '06-ModulesAndHelpers.md', '06-ReusingTestCode.md', '07-AdvancedUsage.md', '07-BDD.md', '08-Customization.md', '09-Data.md', '10-APITesting.md', '11-Codecoverage.md', '12-ContinuousIntegration.md', '12-ParallelExecution.md','APITesting', 'AcceptanceTests', 'AdvancedUsage', 'BDD', 'Codecoverage', 'ContinuousIntegration', 'Customization', 'Data', 'Debugging', 'FunctionalTests', 'GettingStarted', 'Introduction', 'ModulesAndHelpers', 'ParallelExecution', 'Reporting', 'ReusingTestCode', 'UnitTests',
74-
];
7572
$guidesLinks = [];
7673

7774
foreach ($guides as $file) {
78-
$name = substr($file->getBasename(), 0, -3);
75+
$filename = $file->getBasename();
76+
$name = substr($filename, 0, -3);
7977
$titleName = preg_replace("(\d+-)", '', $name);
8078

8179
$link = "/docs/$titleName";
82-
$editLink = 'https://github.com/Codeception/codeception.github.com/edit/master/guides/' . $file->getBasename();
80+
81+
$editLink = 'https://github.com/Codeception/codeception.github.com/edit/master/guides/' . $filename;
8382
$title = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\\1 \\2', $titleName);
8483
$title = preg_replace('/([a-z\d])([A-Z])/', '\\1 \\2', $title);
8584

8685
$contents = file_get_contents($file->getPathname());
87-
$pervVersionLink = in_array($file->getBasename(), $prevVersionDocs) ? '<div class="alert alert-success">💡 <b>You are reading docs for latest Codeception 5</b>. <a href="https://github.com/Codeception/codeception.github.com/blob/4.x/docs/' . $file->getBasename() . '">Read for 4.x</a></div>' : '';
88-
89-
foreach ([$file->getBasename(), $titleName . '.md'] as $filename) {
90-
$this->taskWriteToFile('docs/' . $filename)
91-
->line('---')
92-
->line('layout: doc')
93-
->line("title: $title - Codeception Docs")
94-
->line('---')
95-
->line('')
96-
->line($pervVersionLink)
97-
->line('')
98-
->text($contents)
99-
->line('')
100-
->line('<div class="alert alert-warning"><a href="'.$editLink.'"><strong>Improve</strong> this guide</a></div>')
101-
->run();
86+
if (file_exists("docs/4.x/$titleName.md" )) {
87+
$prevVersionLink = '<div class="alert alert-success">💡 <b>You are reading docs for latest Codeception 5</b>. <a href="/docs/4.x/' . $titleName . '">Read for 4.x</a></div>';
88+
} else {
89+
$prevVersionLink = '';
10290
}
10391

92+
$this->taskWriteToFile('docs/' . $titleName . '.md')
93+
->line('---')
94+
->line('layout: doc')
95+
->line("title: $title - Codeception Docs")
96+
->line('---')
97+
->line('')
98+
->line($prevVersionLink)
99+
->line('')
100+
->text($contents)
101+
->line('')
102+
->line('<div class="alert alert-warning"><a href="'.$editLink.'"><strong>Improve</strong> this guide</a></div>')
103+
->run();
104+
105+
$this->taskWriteToFile('docs/' . $filename)
106+
->line('<meta http-equiv="refresh" content="0;url=https://codeception.com/docs/' . $titleName. '">')
107+
->line('---')
108+
->line('layout: doc')
109+
->line("title: $title - Codeception Docs")
110+
->line('---')
111+
->line('')
112+
->line('<div class="alert alert-warning">')
113+
->line(' See <a href="https://codeception.com/docs/' . $titleName . '">' . $title . '</a>')
114+
->line('</div>')
115+
->run();
116+
104117
$guidesLinks[] = "<li><a href=\"$link\">$title</a></li>";
105118
}
106119
file_put_contents('_includes/guides.html', implode("\n", $guidesLinks));

docs/01-Introduction.md

Lines changed: 4 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,9 @@
1+
<meta http-equiv="refresh" content="0;url=https://codeception.com/docs/Introduction">
12
---
23
layout: doc
34
title: Introduction - Codeception Docs
45
---
56

6-
<div class="alert alert-success">💡 <b>You are reading docs for latest Codeception 5</b>. <a href="https://github.com/Codeception/codeception.github.com/blob/4.x/docs/01-Introduction.md">Read for 4.x</a></div>
7-
8-
# Introduction
9-
10-
The idea behind testing is not new. You can't sleep well if you are not confident
11-
that your latest commit didn't take down the entire application.
12-
Having your application covered with tests gives you more trust in the stability of your application. That's all.
13-
14-
In most cases tests don't guarantee that the application works 100% as it is supposed to.
15-
You can't predict all possible scenarios and exceptional situations for complex apps,
16-
but with tests you can cover the most important parts of your app and at least be sure they work as predicted.
17-
18-
There are plenty of ways to test your application.
19-
The most popular paradigm is [Unit Testing](https://en.wikipedia.org/wiki/Unit_testing).
20-
For web applications, testing just the controller and/or the model doesn't prove that your application is working.
21-
To test the behavior of your application as a whole, you should write functional or acceptance tests.
22-
23-
Codeception supports all three testing types.
24-
Out of the box you have tools for writing unit, functional, and acceptance tests in a unified framework.
25-
26-
| | Unit Tests | Functional Tests | Acceptance Tests
27-
| --- | --- | --- | --- |
28-
| Scope of the test | Single PHP class | PHP Framework (Routing, Database, etc.) | Page in browser (Chrome, Firefox, or [PhpBrowser](https://codeception.com/docs/03-AcceptanceTests#PhpBrowser)) |
29-
| Testing computer needs access to project's PHP files | Yes | Yes | No |
30-
| Webserver required | No | No | Yes |
31-
| JavaScript | No | No | Yes |
32-
| Additional software required | None | None | Drivers for Firefox/Chrome |
33-
| Test execution speed | Very fast | Fast | Slow |
34-
| Configuration file | `Unit.suite.yml` | `Functional.suite.yml` | `Acceptance.suite.yml` |
35-
36-
One of the main advantages of Codeception is that you don't have to decide on just *one* type of testing. You should have all three!
37-
And chances are, that you will (sooner or later) need all three. That's why Codeception consists of three so-called "suites":
38-
A "Unit suite" for all unit tests, a "functional suite" for all functional tests, and an "Acceptance suite" for all acceptance tests.
39-
40-
Let's review those three test types in reverse order.
41-
42-
### Acceptance Tests
43-
44-
How does your client, manager, tester, or any other non-technical person know your website is working? By opening the browser, accessing the site, clicking on links, filling in the forms, and actually seeing the content on a web page. They have no idea of the programming language, framework, database, web-server,
45-
or why the application did (or did not) behave as expected.
46-
47-
This is what acceptance tests are doing. They cover scenarios from a user's perspective.
48-
With acceptance tests, you can be confident that users, following all the defined scenarios, won't get errors.
49-
50-
> **Any website** can be covered with acceptance tests, even if you use a very exotic CMS or framework.
51-
52-
#### Sample acceptance test
53-
54-
```php
55-
$I->amOnPage('/');
56-
$I->click('Sign Up');
57-
$I->submitForm('#signup', [
58-
'username' => 'MilesDavis',
59-
'email' => 'miles@davis.com'
60-
]);
61-
$I->see('Thank you for Signing Up!');
62-
```
63-
64-
### Functional Tests
65-
66-
What if you could check our application without running it on a server?
67-
That way you could see detailed exceptions on errors, have your tests run faster, and check the database against predictable and expected results. That's what functional tests are for.
68-
69-
For functional tests, you emulate a web request (`$_GET` and `$_POST` variables) which returns the HTML response. Inside a test, you can make assertions about the response, and you can check if the data was successfully stored in the database.
70-
71-
For functional tests, your application needs to be structured in order to run in a test environment. Codeception provides modules for all popular PHP frameworks.
72-
73-
#### Sample functional test
74-
75-
```php
76-
$I->amOnPage('/');
77-
$I->click('Sign Up');
78-
$I->submitForm('#signup', ['username' => 'MilesDavis', 'email' => 'miles@davis.com']);
79-
$I->see('Thank you for Signing Up!');
80-
$I->seeEmailIsSent('miles@davis.com', 'Thank you for your registration');
81-
$I->seeInDatabase('users', ['email' => 'miles@davis.com']);
82-
```
83-
84-
> This looks very similar to acceptance tests. The behavior is the same, however, the test is executed inside PHP without launching a real browser.
85-
86-
### Unit Tests
87-
88-
Testing pieces of code before coupling them together is highly important as well. This way,
89-
you can be sure that some deeply hidden feature still works, even if it was not covered by functional or acceptance tests.
90-
This also shows care in producing stable and testable code.
91-
92-
Codeception is created on top of [PHPUnit](https://www.phpunit.de/). If you have experience writing unit tests with PHPUnit
93-
you can continue doing so. Codeception has no problem executing standard PHPUnit tests,
94-
but, additionally, Codeception provides some well-built tools to make your unit tests simpler and cleaner.
95-
96-
Requirements and code can change rapidly,
97-
and unit tests should be updated every time to fit the requirements.
98-
The better you understand the testing scenario, the faster you can update it for new behavior.
99-
100-
#### Sample integration test
101-
102-
```php
103-
public function testSavingUser()
104-
{
105-
$user = new User();
106-
$user->setName('Miles');
107-
$user->setSurname('Davis');
108-
$user->save();
109-
$this->assertEquals('Miles Davis', $user->getFullName());
110-
$this->tester->seeInDatabase('users', [
111-
'name' => 'Miles',
112-
'surname' => 'Davis'
113-
]);
114-
}
115-
```
116-
117-
## Conclusion
118-
119-
The Codeception framework was developed to actually make testing fun.
120-
It allows writing unit, functional, integration, and acceptance tests in a single, coherent style.
121-
122-
All Codeception tests are written in a descriptive manner.
123-
Just by looking at the test body, you can clearly understand what is being tested and how it is performed.
124-
125-
<div class="alert alert-warning"><a href="https://github.com/Codeception/codeception.github.com/edit/master/guides/01-Introduction.md"><strong>Improve</strong> this guide</a></div>
7+
<div class="alert alert-warning">
8+
See <a href="https://codeception.com/docs/Introduction">Introduction</a>
9+
</div>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy