<p align="center">
<img height="30px" src="https://www.eae.pt/images/icons/logo-white.svg"> 
EAST ATLANTIC ENGINEERING
</p>


## Installation
This EAE Base CMS is built on Laravel 8, which requires PHP 8.1+. See Laravel's 
[requirements](https://laravel.com/docs/8.x/installation#server-requirements) for details.

1. You need to copy the .env.example to .env . There you have to set the following:

   * **APP_NAME** - Usually the name of the project. If the name has spaces you need to enclose it in quotes
   * **APP_ENV** - Environment you are running the project. If you are running locally put **local**
   * **APP_DEBUG** - Set to true if you what to see the error stack screen
   * **APP_URL** - The base url for your website. It does not finish with trailing slashes (ex:http://eae-base-cms.lndo.site)
   * **DB_*** - Set the appropriate database credentials. The example credential are correct if you are running lando
   * **MAIL_*** Set the appropriate email service credentials. The example is correct if you are running lando and you what to 
send the emails to mailhog
   * **EAE_ADMIN_DEFAULT_PASSWORD** - Set the default admin password when creating the project. This will be used when you run 
the database seeders
   * **EAE_RECAPTCHA_*** - Set the google recaptcha keys. The backoffice is using recapcha v3
   * **EAE_GOOGLE_API_KEY** - Set the google maps javascript api key

2. Run `lando start` (optional if you are not running lando)

3. Run `composer install` or  `lando composer install` (the last one if you are running lando)

4. Run `php artisan key:generate` or `lando artisan key:generate` (the last one if you are running lando) to generate 
the APP_KEY in .env

5. Run `php artisan migrate` or `lando artisan migrate && lando artisan migrate --path="/database/migrations/project"` (the last one if you are running lando)

6. Run `php artisan db:seed` or `lando artisan db:seed` (the last one if you are running lando)
    - When seeding the DB two example menus will be added to the Menus Table. Change/Add/Remove the menus as necessary.

7. Better yet, just run `lando prep-db`

8. Run `lando php artisan storage:link` to create the link for the storage, to be able to access the uploaded media

After this you should be able to access with APP_URL\admin. 
- Username is `admin`
- Password is the one defined in .env as EAE_ADMIN_DEFAULT_PASSWORD 
- If in development environment (lando) you can check the APP URL with `lando info`

### Tests

#### Unit & Feature Tests (Pest)
The project uses [Pest PHP](https://pestphp.com/) for unit and feature testing.

```bash
# Run all tests
php artisan test
# or with Lando
lando artisan test

# Run with coverage
php artisan test --coverage
```

Tests are located in:
- `tests/Unit/` - Unit tests
- `tests/Feature/` - Feature/integration tests

#### Browser Tests (Laravel Dusk)
Laravel Dusk is available to perform browser tests.

```bash
# Run browser tests
lando test-dusk
```

Tests can be found at `tests/Browser/`.

**ATTENTION**: Running `lando test-dusk` will erase the DB content and drop tables in the end. If you want to manually test/use the app after running Dusk tests, you will need to rebuild the database with `lando prep-db`.

#### CI/CD
Tests run automatically on push to `staging` branch via Bitbucket Pipelines. See `bitbucket-pipelines.yml` for configuration.
