<commit_before># CakePHP3 + Behat and PHPSpec

This is CakePHP3 Blog Tutorial Application Example For Testing by Behat and PHPSpec

## Installing and Runnning the example

### Install

I use Cakebox for creating application.
Using it, easy to run the example application.

1: Install Vagrant and Virtualbox

- [Vagrant](https://www.vagrantup.com/)
- [Virtualbox](https://www.virtualbox.org/)

2: Install Cakebox

```
localhost:any     $ git clone https://github.com/alt3/cakebox.git
localhost:any     $ cd cakebox
localhost:cakebox $ cp Cakebox.yaml.default Cakebox.yaml
localhost:cakebox $ vagrant up
```

3: Install example application

```
localhost:cakebox $ vagrant ssh
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-24-generic x86_64)

vagrant@cakebox $ cakebox application add blog-tutorial.app --source https://github.com/sizuhiko/cakephp3-bdd-example.git --webroot blog-tutorial.app
```

It will print out logs of installation followings:

```
Creating application http://blog-tutorial.app

Configuring installer
Creating installation directory
Git installing user specified application sources
Creating virtual host
* Successfully created PHP-FPM virtual host
Creating databases
* Successfully created main database
* Successfully created test database
Configuring permissions
Updating configuration files
Application created using:
  database => blog-tutorial_app
  framework_human => user specified
  framework_short => custom
  installation_method => git
  path => /home/vagrant/Apps/blog-tutorial.app
  source => https://github.com/sizuhiko/cakephp3-bdd-example.git
  url => blog-tutorial.app
  webroot => blog-tutorial.app
Please note:
  => Configuration files are not automatically updated for user specified applications.
  => Make sure to manually update your database credentials, plugins, etc.

Remember to update your hosts file with: 10.33.10.10 http://blog-tutorial.app

Installation completed successfully
```

After installation completed successfully, create directories and install dependencies.

```
vagrant@cakebox $ cd Apps/blog-tutorial.app
vagrant@cakebox:~/Apps/blog-tutorial.app$ mkdir tmp 
vagrant@cakebox:~/Apps/blog-tutorial.app$ mkdir logs
vagrant@cakebox:~/Apps/blog-tutorial.app$ cp config/app.default.php config/app.php
vagrant@cakebox:~/Apps/blog-tutorial.app$ composer install 

Generating autoload files
Set Folder Permissions ? (Default to Y) [Y,n]? 
Updated Security.salt value in config/app.php
```

### Configuration

#### Nginx Config (webroot)

Should change webroot.

```
sudo vi /etc/nginx/sites-available/blog-tutorial.app
```

After installing application, webroot is not installed path.

```
root blog-tutorial.app;
```

Change `root` to real path of installed application.

```
root /home/vagrant/Apps/blog-tutorial.app/webroot;
```

#### Example Application Config

Edit section of database connection in `config/app.php`.

```php
    'Datasources' => [
        'default' => [
            'className' => 'Cake\Database\Connection',
            'driver' => 'Cake\Database\Driver\Mysql',
            'persistent' => false,
            'host' => 'localhost',
            'username' => 'cakebox',    // CHANGE
            'password' => '<PASSWORD>',
            'database' => 'blog-tutorial_app', // CHANGE
            'encoding' => 'utf8',<commit_msg>set path of  webroot when add application<commit_after># CakePHP3 + Behat and PHPSpec

This is CakePHP3 Blog Tutorial Application Example For Testing by Behat and PHPSpec

## Installing and Runnning the example

### Install

I use Cakebox for creating application.
Using it, easy to run the example application.

1: Install Vagrant and Virtualbox

- [Vagrant](https://www.vagrantup.com/)
- [Virtualbox](https://www.virtualbox.org/)

2: Install Cakebox

```
localhost:any     $ git clone https://github.com/alt3/cakebox.git
localhost:any     $ cd cakebox
localhost:cakebox $ cp Cakebox.yaml.default Cakebox.yaml
localhost:cakebox $ vagrant up
```

3: Install example application

```
localhost:cakebox $ vagrant ssh
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-24-generic x86_64)

vagrant@cakebox $ cakebox application add blog-tutorial.app --source https://github.com/sizuhiko/cakephp3-bdd-example.git --webroot /home/vagrant/Apps/blog-tutorial.app/webroot
```

It will print out logs of installation followings:

```
Creating application http://blog-tutorial.app

Configuring installer
Creating installation directory
Git installing user specified application sources
Creating virtual host
* Successfully created PHP-FPM virtual host
Creating databases
* Successfully created main database
* Successfully created test database
Configuring permissions
Updating configuration files
Application created using:
  database => blog-tutorial_app
  framework_human => user specified
  framework_short => custom
  installation_method => git
  path => /home/vagrant/Apps/blog-tutorial.app
  source => https://github.com/sizuhiko/cakephp3-bdd-example.git
  url => blog-tutorial.app
  webroot => blog-tutorial.app
Please note:
  => Configuration files are not automatically updated for user specified applications.
  => Make sure to manually update your database credentials, plugins, etc.

Remember to update your hosts file with: 10.33.10.10 http://blog-tutorial.app

Installation completed successfully
```

After installation completed successfully, create directories and install dependencies.

```
vagrant@cakebox $ cd Apps/blog-tutorial.app
vagrant@cakebox:~/Apps/blog-tutorial.app$ mkdir tmp 
vagrant@cakebox:~/Apps/blog-tutorial.app$ mkdir logs
vagrant@cakebox:~/Apps/blog-tutorial.app$ cp config/app.default.php config/app.php
vagrant@cakebox:~/Apps/blog-tutorial.app$ composer install 

Generating autoload files
Set Folder Permissions ? (Default to Y) [Y,n]? 
Updated Security.salt value in config/app.php
```

### Configuration

#### Example Application Config

Edit section of database connection in `config/app.php`.

```php
    'Datasources' => [
        'default' => [
            'className' => 'Cake\Database\Connection',
            'driver' => 'Cake\Database\Driver\Mysql',
            'persistent' => false,
            'host' => 'localhost',
            'username' => 'cakebox',    // CHANGE
            'password' => '<PASSWORD>',
            'database' => 'blog-tutorial_app', // CHANGE
            'encoding' => 'utf8',
{'fraction_non_alphanumeric': 0.10925429607441274, 'fraction_numerical': 0.010089862840927007, 'mean_word_length': 4.046937151949085, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, 'https://': 10, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '996346', 'n_tokens_mistral': 2025, 'n_tokens_neox': 1859, 'n_words': 548}