# Test Directory Migration Map

This document records the file moves and namespace changes made during the test directory reorganization per SDD specification (lines 400-463).

## Migration Date
2025-12-06

## Summary

The test directory structure has been reorganized to follow a consistent pattern where:
- All unit tests reside under `tests/Unit/{Module}/`
- All integration tests reside under `tests/Integration/{Module}/`
- All fixtures reside under `tests/Fixtures/{Module}/`
- Support classes (TestCase extensions) reside under `tests/Support/`

## File Migrations

### Employee Tests

| Old Location | New Location | Old Namespace | New Namespace |
|-------------|--------------|---------------|---------------|
| `Employee/Unit/EmployeeTest.php` | `Unit/Employee/EmployeeTest.php` | `Tests\Employee\Unit` | `Tests\Unit\Employee` |
| `Employee/Unit/SyncResultTest.php` | `Unit/Employee/SyncResultTest.php` | `Tests\Employee\Unit` | `Tests\Unit\Employee` |
| `Employee/Integration/EmployeeApiControllerTest.php` | `Integration/Employee/EmployeeApiControllerTest.php` | `Tests\Employee\Integration` | `Tests\Integration\Employee` |
| `Employee/Integration/EmployeeDatabaseTest.php` | `Integration/Employee/EmployeeDatabaseTest.php` | `Tests\Employee\Integration` | `Tests\Integration\Employee` |
| `Employee/Integration/EmployeeManagerTest.php` | `Integration/Employee/EmployeeManagerTest.php` | `Tests\Employee\Integration` | `Tests\Integration\Employee` |
| `Employee/Fixtures/EmployeeFixtures.php` | `Fixtures/Employee/EmployeeFixtures.php` | `Tests\Employee\Fixtures` | `Tests\Fixtures\Employee` |
| `Employee/EmployeeTestCase.php` | `Support/EmployeeTestCase.php` | `Tests\Employee` | `Tests\Support` |

### Workbook Tests

| Old Location | New Location | Old Namespace | New Namespace |
|-------------|--------------|---------------|---------------|
| `Workbook/Unit/TaskListManagerTest.php` | `Unit/Workbook/TaskListManagerTest.php` | `Tests\Workbook\Unit` | `Tests\Unit\Workbook` |
| `Workbook/Unit/NoteTest.php` | `Unit/Workbook/NoteTest.php` | `Tests\Workbook\Unit` | `Tests\Unit\Workbook` |
| `Workbook/Unit/NoteCommentTest.php` | `Unit/Workbook/NoteCommentTest.php` | `Tests\Workbook\Unit` | `Tests\Unit\Workbook` |
| `Workbook/Unit/NoteReactionTest.php` | `Unit/Workbook/NoteReactionTest.php` | `Tests\Workbook\Unit` | `Tests\Unit\Workbook` |
| `Workbook/Unit/NoteManagerTest.php` | `Unit/Workbook/NoteManagerTest.php` | `Tests\Workbook\Unit` | `Tests\Unit\Workbook` |
| `Workbook/Unit/TaskCommentTest.php` | `Unit/Workbook/TaskCommentTest.php` | `Tests\Workbook\Unit` | `Tests\Unit\Workbook` |
| `Workbook/Unit/TaskCompletionTest.php` | `Unit/Workbook/TaskCompletionTest.php` | `Tests\Workbook\Unit` | `Tests\Unit\Workbook` |
| `Workbook/Unit/WhiteboardManagerTest.php` | `Unit/Workbook/WhiteboardManagerTest.php` | `Tests\Workbook\Unit` | `Tests\Unit\Workbook` |
| `Workbook/Unit/WorkbookAblyTest.php` | `Unit/Workbook/WorkbookAblyTest.php` | `Tests\Workbook\Unit` | `Tests\Unit\Workbook` |
| `Workbook/Unit/Phase5bTest.php` | `Unit/Workbook/Phase5bTest.php` | `Tests\Workbook\Unit` | `Tests\Unit\Workbook` |
| `Workbook/Fixtures/TaskFixtures.php` | `Fixtures/Workbook/TaskFixtures.php` | `Tests\Workbook\Fixtures` | `Tests\Fixtures\Workbook` |
| `Workbook/Fixtures/NoteFixtures.php` | `Fixtures/Workbook/NoteFixtures.php` | `Tests\Workbook\Fixtures` | `Tests\Fixtures\Workbook` |
| `Workbook/Fixtures/WhiteboardFixtures.php` | `Fixtures/Workbook/WhiteboardFixtures.php` | `Tests\Workbook\Fixtures` | `Tests\Fixtures\Workbook` |

### Task Tests

| Old Location | New Location | Old Namespace | New Namespace |
|-------------|--------------|---------------|---------------|
| `Task/Unit/TaskTest.php` | `Unit/Task/TaskTest.php` | `Tests\Task\Unit` | `Tests\Unit\Task` |
| `Task/Unit/TaskGroupTest.php` | `Unit/Task/TaskGroupTest.php` | `Tests\Task\Unit` | `Tests\Unit\Task` |
| `Task/Unit/TaskReorderTest.php` | `Unit/Task/TaskReorderTest.php` | `Tests\Task\Unit` | `Tests\Unit\Task` |
| `Task/Unit/TaskSchedulingTest.php` | `Unit/Task/TaskSchedulingTest.php` | `Tests\Task\Unit` | `Tests\Unit\Task` |

### DigitalSign Tests

| Old Location | New Location | Old Namespace | New Namespace |
|-------------|--------------|---------------|---------------|
| `DigitalSign/Unit/SlideTagTest.php` | `Unit/DigitalSign/SlideTagTest.php` | `Tests\DigitalSign\Unit` | `Tests\Unit\DigitalSign` |

### EventManagement Tests

| Old Location | New Location | Old Namespace | New Namespace |
|-------------|--------------|---------------|---------------|
| `EventManagement/Unit/Models/EventTest.php` | `Unit/EventManagement/Models/EventTest.php` | `Tests\EventManagement\Unit\Models` | `Tests\Unit\EventManagement\Models` |
| `EventManagement/Unit/Adapters/AbstractAdapterTest.php` | `Unit/EventManagement/Adapters/AbstractAdapterTest.php` | `Tests\EventManagement\Unit\Adapters` | `Tests\Unit\EventManagement\Adapters` |
| `EventManagement/Unit/Adapters/IntegrationExceptionTest.php` | `Unit/EventManagement/Adapters/IntegrationExceptionTest.php` | `Tests\EventManagement\Unit\Adapters` | `Tests\Unit\EventManagement\Adapters` |
| `EventManagement/Unit/Services/IntegrationServiceTest.php` | `Unit/EventManagement/Services/IntegrationServiceTest.php` | `Tests\EventManagement\Unit\Services` | `Tests\Unit\EventManagement\Services` |
| `EventManagement/Unit/Services/EventPhaseProcessorTest.php` | `Unit/EventManagement/Services/EventPhaseProcessorTest.php` | `Tests\EventManagement\Unit\Services` | `Tests\Unit\EventManagement\Services` |

### Core Tests

| Old Location | New Location | Old Namespace | New Namespace |
|-------------|--------------|---------------|---------------|
| `Unit/BuyQueueTest.php` | `Unit/Core/BuyQueueTest.php` | `Tests\Unit` | `Tests\Unit\Core` |
| `Unit/ApiNewBuyTest.php` | `Integration/Api/NewBuyApiTest.php` | `Tests\Unit` | `Tests\Integration\Api` |

## Unchanged Directories

The following directories remain in their original locations:

- `Unit/ComebackCash/` - Already follows the correct pattern
- `Unit/Autoload/` - Already follows the correct pattern
- `Unit/Infrastructure/` - Already follows the correct pattern
- `Integration/ComebackCash/` - Already follows the correct pattern

## New Directory Structure

```
tests/
├── Unit/
│   ├── Autoload/             (unchanged)
│   ├── ComebackCash/         (unchanged)
│   ├── Core/                 (NEW)
│   │   └── BuyQueueTest.php
│   ├── DigitalSign/          (NEW)
│   │   └── SlideTagTest.php
│   ├── Employee/             (NEW)
│   │   ├── EmployeeTest.php
│   │   └── SyncResultTest.php
│   ├── EventManagement/      (NEW)
│   │   ├── Adapters/
│   │   │   ├── AbstractAdapterTest.php
│   │   │   └── IntegrationExceptionTest.php
│   │   ├── Models/
│   │   │   └── EventTest.php
│   │   └── Services/
│   │       ├── EventPhaseProcessorTest.php
│   │       └── IntegrationServiceTest.php
│   ├── Infrastructure/       (unchanged)
│   ├── Task/                 (NEW)
│   │   ├── TaskGroupTest.php
│   │   ├── TaskReorderTest.php
│   │   ├── TaskSchedulingTest.php
│   │   └── TaskTest.php
│   └── Workbook/             (NEW)
│       ├── NoteCommentTest.php
│       ├── NoteManagerTest.php
│       ├── NoteReactionTest.php
│       ├── NoteTest.php
│       ├── Phase5bTest.php
│       ├── TaskCommentTest.php
│       ├── TaskCompletionTest.php
│       ├── TaskListManagerTest.php
│       ├── WhiteboardManagerTest.php
│       └── WorkbookAblyTest.php
├── Integration/
│   ├── Api/                  (NEW)
│   │   └── NewBuyApiTest.php
│   ├── ComebackCash/         (unchanged)
│   └── Employee/             (NEW)
│       ├── EmployeeApiControllerTest.php
│       ├── EmployeeDatabaseTest.php
│       └── EmployeeManagerTest.php
├── Fixtures/
│   ├── Core/                 (NEW - placeholder)
│   ├── Employee/             (NEW)
│   │   └── EmployeeFixtures.php
│   └── Workbook/             (NEW)
│       ├── NoteFixtures.php
│       ├── TaskFixtures.php
│       └── WhiteboardFixtures.php
├── Mocks/                    (NEW - Phase 2 Complete)
│   ├── PdoMockBuilder.php    (23 tests)
│   ├── TwilioMock.php        (28 tests)
│   ├── VonageMock.php        (22 tests)
│   ├── RedisMock.php         (57 tests)
│   └── StoreMock.php         (26 tests)
├── Support/                  (NEW)
│   └── EmployeeTestCase.php
├── DatabaseTestCase.php      (unchanged)
└── bootstrap.php             (updated)
```

## Namespace Patterns

The new namespace patterns follow these conventions:

- **Unit tests**: `Tests\Unit\{Module}\{Class}Test`
- **Integration tests**: `Tests\Integration\{Module}\{Class}Test`
- **Fixtures**: `Tests\Fixtures\{Module}\{Class}Fixtures`
- **Support classes**: `Tests\Support\{Class}`

## Bootstrap Changes

The `bootstrap.php` file was updated to reflect the new fixture locations:

```php
// OLD
require_once __DIR__ . '/Employee/Fixtures/EmployeeFixtures.php';
require_once __DIR__ . '/Employee/EmployeeTestCase.php';
require_once __DIR__ . '/Workbook/Fixtures/TaskFixtures.php';
require_once __DIR__ . '/Workbook/Fixtures/NoteFixtures.php';

// NEW
require_once __DIR__ . '/Support/EmployeeTestCase.php';
require_once __DIR__ . '/Fixtures/Employee/EmployeeFixtures.php';
require_once __DIR__ . '/Fixtures/Workbook/TaskFixtures.php';
require_once __DIR__ . '/Fixtures/Workbook/NoteFixtures.php';
require_once __DIR__ . '/Fixtures/Workbook/WhiteboardFixtures.php';
```

## Old Directories to Remove

After verifying tests pass, the following old directories can be removed:

- `tests/Employee/` (entire directory)
- `tests/Workbook/` (entire directory)
- `tests/Task/` (entire directory)
- `tests/DigitalSign/` (entire directory)
- `tests/EventManagement/` (entire directory)
- `tests/Unit/BuyQueueTest.php` (moved to Unit/Core/)
- `tests/Unit/ApiNewBuyTest.php` (moved to Integration/Api/)

---

## Phase 2: Mock Library (Completed 2025-12-06)

The following mock classes were added to support isolated unit testing:

| Mock Class | Purpose | Tests | Features |
|------------|---------|-------|----------|
| **PdoMockBuilder** | Fluent builder for PDO mocks | 23 | `expectQuery()->withParams()->willReturn()->build()` |
| **TwilioMock** | Mock Twilio REST Client | 28 | `expectSend()`, `willSucceed()`, `willFail()`, `verify()` |
| **VonageMock** | Mock Vonage SMS API | 22 | Full response simulation, credential verification |
| **RedisMock** | In-memory Predis mock | 57 | get/set, hget/hset, lpush/rpop/lrange, expire/ttl |
| **StoreMock** | Fluent Store factory | 26 | `withTypeNum()`, `withIntegrations()`, `withTimezone()` |

**Total: 156 tests, 279 assertions**

### Mock Test Locations

```
tests/Unit/Infrastructure/
├── PdoMockBuilderTest.php
├── TwilioMockTest.php
├── VonageMockTest.php
├── RedisMockTest.php
└── StoreMockTest.php
```

### SDD Compliance

All mock classes implement the interfaces specified in SDD lines 503-530:
- ✅ PdoMockBuilder: All 7 methods implemented + 2 extras
- ✅ TwilioMock: All 4 methods implemented + extras
- ✅ StoreMock: All 4 methods implemented + extras
- ✅ VonageMock: Follows TwilioMock pattern
- ✅ RedisMock: All required operations + extras
