Skip to content

Commit e67a576

Browse files
Adding redirect to Joomla Browser (#484)
* Adding redirect to Joomla Browser See Codeception/module-symfony#98 (comment) * Update for.html
1 parent a223a37 commit e67a576

File tree

2 files changed

+2
-206
lines changed

2 files changed

+2
-206
lines changed

_includes/for.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ <h4>WordPress</h4>
2727

2828
<div class="row casestudy">
2929
<div class="col-sm-4">
30-
<a href="/for/joomla" class="item img-thumbnail bg-white item--joomla">
30+
<a href="https://github.com/joomla-projects/joomla-browser" class="item img-thumbnail bg-white item--joomla">
3131
<div>
3232
<img src="/images/frameworks/joomla.svg" alt="joomla">
3333
<h4>joomla</h4>

for/joomla.md

Lines changed: 1 addition & 205 deletions
Original file line numberDiff line numberDiff line change
@@ -1,211 +1,7 @@
1+
<meta http-equiv="refresh" content="0;url=https://github.com/joomla-projects/joomla-browser">
12
---
23
layout: page
34
title: Codeception for Joomla
45
hero: joomla_hero.html
5-
sidebar: |
6-
7-
## Codeception Tests
8-
9-
* Combine **all testing levels** (acceptance, functional, unit)
10-
* **Scenario-Driven**: described in easy to get PHP DSL
11-
* Provide common actions and assertions
12-
13-
## Reference
14-
15-
* [Joomla Browser](http://codeception.com/addons#joomla-browserhttpsgithubcomjoomla-projectsjoomla-browser)
16-
* [Demo Tested Extension](https://github.com/joomla-extensions/weblinks#tests)
17-
18-
---
19-
20-
Written by [**Javier Gomez**](https://github.com/javigomez)
216

227
---
23-
24-
## Setup
25-
Create a Joomla website in your local web server.
26-
27-
Go to the folder where your website is located and run:
28-
29-
```bash
30-
composer require codeception/codeception codeception/module-phpbrowser codeception/module-asserts --dev
31-
```
32-
33-
Then run:
34-
35-
```
36-
vendor/bin/codecept bootstrap --empty
37-
```
38-
39-
Previous command will have createed `codeception.yml` and `tests` directory.
40-
41-
### Acceptance Testing
42-
43-
#### Using headless browser
44-
45-
To test the User Interface of a Joomla Template or an Extension (plugin, module, component, language pack,...) you should simulate the user interaction with a browser.
46-
47-
For UI testing you will the first step will be to create an acceptance tests suite:
48-
49-
```
50-
vendor/bin/codecept generate:suite acceptance
51-
```
52-
53-
This will create `acceptance.suite.yml` and `acceptance` folder inside `tests`.
54-
55-
```yaml
56-
class_name: AcceptanceTester
57-
modules:
58-
enabled:
59-
- PhpBrowser:
60-
url: http://joomla.box/codeception/
61-
- \Helper\Acceptance
62-
```
63-
64-
Acceptance tests should be described in Cest format. Run Cest test generator to generate your very first test `tests/acceptance/AdminLoginCest.php`:
65-
66-
```
67-
vendor/bin/codecept generate:cest acceptance AdminLoginCest
68-
```
69-
70-
Each method of a Cest class (except `_before` and `_after`) is a test. Tests use `$I` object (instance of `AcceptanceTester` class) to perform actions on a webpage.
71-
72-
Modify your `tests/acceptance/AdminLoginCest.php` using the following example code:
73-
74-
```php
75-
<?php
76-
77-
class AdminLoginCest
78-
{
79-
public function login(AcceptanceTester $I)
80-
{
81-
$I->amOnPage('/administrator/index.php');
82-
$I->comment('Fill Username Text Field');
83-
$I->fillField('#mod-login-username', 'admin');
84-
$I->comment('Fill Password Text Field');
85-
$I->fillField('#mod-login-password', 'admin');
86-
$I->comment('I click Login button');
87-
$I->click('Log in');
88-
$I->comment('I see Administrator Control Panel');
89-
$I->see('Control Panel', '.page-title');
90-
}
91-
}
92-
```
93-
94-
To generate method stubs for `AcceptanceTester` run:
95-
96-
```
97-
vendor/bin/codecept build
98-
```
99-
100-
Now you are able to run your first test:
101-
102-
103-
```
104-
vendor/bin/codecept run acceptance
105-
```
106-
107-
Or, try this command to see the execution step by step:
108-
109-
```
110-
vendor/bin/codecept run acceptance --steps
111-
```
112-
113-
#### Using a real browser
114-
115-
Previous execution was done using a headless browser: PHPBrowser. This is the fastest way to run User Interface tests since it doesn’t require running an actual browser. Instead, uses a PHP web scraper, which acts like a browser (it sends a request, then receives and parses the response). Read more about PHPBrowser at [http://codeception.com/docs/03-AcceptanceTests#PHP-Browser](http://codeception.com/docs/03-AcceptanceTests#PHP-Browser).
116-
117-
If you prefer to run your test on a real browser like Firefox you are required to use the Codeception Webdriver Module. Unlike PHPBrowser it will allow you to test the visibility of elements or test javascript interactions (but the test execution will be considerably slower).
118-
119-
The Joomla Community provides an extended Webdriver Codeception Module called [Joomla-Browser](http://codeception.com/addons#Joomla-Browser). With Joomla-Browser you can execute, with one command, common joomla actions like: install Joomla, do Adminitrator Login, publish a module, and many more. See the full list at [Joomla Browser Documentation](https://github.com/joomla-projects/joomla-browser#joomla-browser-codeception-module).
120-
121-
In the following example we are going to refactor our previous "administrator login test" by using Joomla-Browser and executing it in a Firefox browser:
122-
123-
First, install Joomla-browser:
124-
125-
```bash
126-
composer require joomla-projects/joomla-browser --dev
127-
```
128-
129-
Modify your acceptance.suite.yml file like as follows:
130-
131-
```yaml
132-
class_name: AcceptanceTester
133-
modules:
134-
enabled:
135-
- JoomlaBrowser
136-
- AcceptanceHelper
137-
config:
138-
JoomlaBrowser:
139-
url: 'http://localhost/tests/joomla-cms3' # the url that points to the joomla installation at /tests/system/joomla-cms
140-
browser: 'firefox'
141-
window_size: 1024x768
142-
capabilities:
143-
unexpectedAlertBehaviour: 'accept'
144-
username: 'admin' # UserName for the Administrator
145-
password: 'admin' # Password for the Administrator
146-
database host: 'localhost' # place where the Application is Hosted #server Address
147-
database user: 'root' # MySQL Server user ID, usually root
148-
database password: '' # MySQL Server password, usually empty or root
149-
database name: 'testjoomla' # DB Name, at the Server
150-
database type: 'mysqli' # type in lowercase one of the options: MySQL\MySQLi\PDO
151-
database prefix: 'jos_' # DB Prefix for tables
152-
install sample data: 'No' # Do you want to Download the Sample Data Along with Joomla Installation, then keep it Yes
153-
sample data: 'Default English (GB) Sample Data' # Default Sample Data
154-
admin email: 'admin@mydomain.com' # email Id of the Admin
155-
language: 'English (United Kingdom)' # Language in which you want the Application to be Installed
156-
joomla folder: 'home/.../path to Joomla Folder' # Path to Joomla installation where we execute the tests
157-
158-
```
159-
160-
Modify your previous `tests/acceptance/AdminLoginCest.php` using the following example code:
161-
162-
```php
163-
<?php
164-
165-
class AdminLoginCest
166-
{
167-
public function login(AcceptanceTester $I)
168-
{
169-
$I->doAdministratorLogin();
170-
}
171-
}
172-
```
173-
174-
Run the test:
175-
176-
```
177-
vendor/bin/codecept run acceptance --steps
178-
```
179-
180-
**Important note**, in order to run the previous test you need to have [Selenium](http://docs.seleniumhq.org/download/) running in your system. If you are new to Selenium, you can find an example of useage at the [Weblinks Joomla Official supported extension](https://github.com/joomla-extensions/weblinks#tests). Just follow the "running the tests" instructions to learn how to easily lauch Selenium in your system.
181-
182-
<div class="alert alert-warning">
183-
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
184-
Continue to <a href="http://codeception.com/docs/03-AcceptanceTests">Acceptance Testing Guide &raquo;</a>
185-
</div>
186-
187-
188-
189-
### BDD
190-
191-
If you prefer to describe application with feature files, Codeception can turn them to acceptance tests.
192-
193-
Your previous test would look like:
194-
195-
```gherkin
196-
Feature: administrator login
197-
In order to manage my web application
198-
As administrator
199-
I need to be able to login
200-
201-
Scenario: Successful login
202-
Given I am registered administrator named "admin"
203-
When I login into Joomla Administrator with username "admin" and password "admin"
204-
Then I should see administrator dashboard
205-
```
206-
207-
<div class="alert alert-warning">
208-
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
209-
Continue to <a href="http://codeception.com/docs/07-BDD">Behavior Driven Development Guide &raquo;</a>
210-
</div>
211-

0 commit comments

Comments
 (0)