> For the complete documentation index, see [llms.txt](https://docs.enicebakerygh.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.enicebakerygh.com/devops-and-quality-assurance/testing.md).

# Automated Testing & QA Guide

This document details the test suites, execution procedures, assertion metrics, and CI/CD pipelines governing the Eniceberny Bakery and Culinary Hub platform.

***

## 1. Test Architecture & Standards

Quality assurance is enforced through comprehensive automated testing using **PHPUnit** and Laravel's HTTP test utilities:

* **Isolated In-Memory Database**: All test suites execute against high-speed in-memory SQLite instances (`:memory:`), guaranteeing complete test isolation without residual side-effects.
* **Automated Seeding Integration**: Test classes leverage the `RefreshDatabase` trait with `protected bool $seed = true;`, ensuring authentic catalog categories, menu delicacies, and role permissions are present during every test run.
* **Zero-Mock Financial Verification**: Payment callbacks, cart additions, discount deductions, and order conversions are executed against real Eloquent database models.

***

## 2. Comprehensive Test Suite Inventory (82 Tests, 378 Assertions)

The platform test suite contains **82 automated tests** across six specialized feature test classes:

| Test Suite Class                       | File Path                                            | Tests | Key Focus Areas                                                                                                                                                     |
| -------------------------------------- | ---------------------------------------------------- | :---: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`AdminTest`**                        | `tests/Feature/AdminTest.php`                        |   13  | Access control, live dashboard metrics, order status updates, POS transactions, modular settings, brand logo uploads, security file rejections.                     |
| **`CmsAndBroadcastTest`**              | `tests/Feature/CmsAndBroadcastTest.php`              |   6   | Marketing copy updates, testimonials CRUD, CMS pages, email broadcast center, customer permission boundaries.                                                       |
| **`Phase25ErpAndGhanaComplianceTest`** | `tests/Feature/Phase25ErpAndGhanaComplianceTest.php` |   10  | Ghana Act 843 compliance, terms of service, granular staff permissions, public invoice lookups, catering conversion to orders, takeaway/dine-in POS modes.          |
| **`Phase2CommerceTest`**               | `tests/Feature/Phase2CommerceTest.php`               |   20  | Customer account profiles, delivery address management, order history, Paystack webhooks, POS sales, coupon code validation, sliding cart drawer data.              |
| **`Phase3OperationsAndCmsTest`**       | `tests/Feature/Phase3OperationsAndCmsTest.php`       |   10  | Admin navigation architecture, product variants and options, homepage sections, catering services/quotes, customer addresses ledger, audit log redaction, sitemaps. |
| **`StorefrontTest`**                   | `tests/Feature/StorefrontTest.php`                   |   14  | Cinematic landing page sections, shop catalog filters, end-to-end checkout flow, printable receipts, OTP verification, back-to-storefront auth buttons.             |
| **`ExampleTest`**                      | `tests/Feature/ExampleTest.php`                      |   1   | Basic HTTP 200 health verification.                                                                                                                                 |

***

## 3. Running Tests Locally

### 3.1 Run Complete Test Suite

Execute the entire test suite from the repository root:

```bash
php artisan test
```

Expected output:

```
  PASS  Tests\Feature\AdminTest
  PASS  Tests\Feature\CmsAndBroadcastTest
  PASS  Tests\Feature\ExampleTest
  PASS  Tests\Feature\Phase25ErpAndGhanaComplianceTest
  PASS  Tests\Feature\Phase2CommerceTest
  PASS  Tests\Feature\Phase3OperationsAndCmsTest
  PASS  Tests\Feature\StorefrontTest

  Tests:    82 passed (378 assertions)
  Duration: ~15s
```

### 3.2 Run Specific Test Classes or Filters

Target individual feature areas during local development:

```bash
# Run only Admin tests
php artisan test --filter AdminTest

# Run only Storefront & Checkout tests
php artisan test --filter StorefrontTest

# Run Ghana compliance and ERP tests
php artisan test --filter Phase25ErpAndGhanaComplianceTest

# Run a specific single test method
php artisan test --filter test_catering_inquiry_can_be_converted_to_official_order
```

***

## 4. Continuous Integration Pipeline (GitHub Actions)

Every pull request and push to the `main` branch automatically triggers the automated CI/CD pipeline defined in `.github/workflows/ci.yml`:

```mermaid
graph TD
    A[Push / PR to main] --> B[GitHub Actions Runner: ubuntu-latest]
    B --> C[Setup PHP 8.4 with required extensions]
    B --> D[Setup Node.js 20 with npm cache]
    C --> E[composer install --prefer-dist --optimize-autoloader]
    D --> F[npm ci && npm run build]
    E --> G[Copy .env.example & Generate Key]
    F --> G
    G --> H[php artisan test --colors=always]
    H -->|All 82 Tests Pass| I[Production Render Deployment Trigger]
    H -->|Any Failure| J[Halt & Reject Deployment]
```

### CI Requirements:

* **PHP Version**: `8.4` (matching production runtime and Symfony 8.1 dependencies).
* **PHP Extensions**: `mbstring`, `xml`, `ctype`, `iconv`, `intl`, `pdo`, `pdo_sqlite`, `pdo_pgsql`, `bcmath`, `gd`, `zip`.
* **Node.js**: `20.x` compiling Tailwind v3 and Vite bundles.
* **Coverage**: Fast execution without xdebug overhead (`coverage: none`).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.enicebakerygh.com/devops-and-quality-assurance/testing.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
