|
| 1 | +# Testing Guide |
| 2 | + |
| 3 | +## Quick Start |
| 4 | + |
| 5 | +```bash |
| 6 | +# Run all tests |
| 7 | +composer test |
| 8 | + |
| 9 | +# Run only unit tests |
| 10 | +composer test:unit |
| 11 | + |
| 12 | +# Run only E2E tests |
| 13 | +composer test:e2e |
| 14 | + |
| 15 | +# Run tests with coverage report |
| 16 | +composer test:coverage |
| 17 | +``` |
| 18 | + |
| 19 | +## Test Structure |
| 20 | + |
| 21 | +``` |
| 22 | +tests/ |
| 23 | +├── Models/ # Unit tests (validation, model behavior) |
| 24 | +│ └── Kakao/ |
| 25 | +│ └── Bms/ |
| 26 | +│ ├── BmsModelsTest.php |
| 27 | +│ └── BmsValidatorTest.php |
| 28 | +└── E2E/ # End-to-end tests (actual API calls) |
| 29 | + └── BmsFreeSendTest.php |
| 30 | +``` |
| 31 | + |
| 32 | +## E2E Tests Configuration |
| 33 | + |
| 34 | +E2E tests require environment variables to connect to the SOLAPI API: |
| 35 | + |
| 36 | +```bash |
| 37 | +export SOLAPI_API_KEY="your-api-key" |
| 38 | +export SOLAPI_API_SECRET="your-api-secret" |
| 39 | +export SOLAPI_KAKAO_PF_ID="your-kakao-pf-id" |
| 40 | +export SOLAPI_SENDER_NUMBER="01012345678" |
| 41 | +export SOLAPI_RECIPIENT_NUMBER="01087654321" |
| 42 | +export SOLAPI_TEST_IMAGE_PATH="/path/to/test/image.jpg" # Optional |
| 43 | +``` |
| 44 | + |
| 45 | +Without these variables, E2E tests will be skipped automatically. |
| 46 | + |
| 47 | +### Running E2E Tests |
| 48 | + |
| 49 | +```bash |
| 50 | +# Set environment variables and run |
| 51 | +SOLAPI_API_KEY=xxx SOLAPI_API_SECRET=xxx \ |
| 52 | +SOLAPI_KAKAO_PF_ID=xxx \ |
| 53 | +SOLAPI_SENDER_NUMBER=01012345678 \ |
| 54 | +SOLAPI_RECIPIENT_NUMBER=01087654321 \ |
| 55 | +composer test:e2e |
| 56 | +``` |
| 57 | + |
| 58 | +Or use a `.env` file with a tool like `dotenv`: |
| 59 | + |
| 60 | +```bash |
| 61 | +# .env.test (do not commit this file) |
| 62 | +SOLAPI_API_KEY=your-api-key |
| 63 | +SOLAPI_API_SECRET=your-api-secret |
| 64 | +SOLAPI_KAKAO_PF_ID=your-pf-id |
| 65 | +SOLAPI_SENDER_NUMBER=01012345678 |
| 66 | +SOLAPI_RECIPIENT_NUMBER=01087654321 |
| 67 | +``` |
| 68 | + |
| 69 | +## PHPUnit Direct Commands |
| 70 | + |
| 71 | +```bash |
| 72 | +# Run specific test file |
| 73 | +./vendor/bin/phpunit tests/E2E/BmsFreeSendTest.php |
| 74 | + |
| 75 | +# Run specific test method |
| 76 | +./vendor/bin/phpunit --filter testSendBmsTextMinimal |
| 77 | + |
| 78 | +# Run with verbose output |
| 79 | +./vendor/bin/phpunit --testdox |
| 80 | + |
| 81 | +# List all available tests |
| 82 | +./vendor/bin/phpunit --list-tests |
| 83 | +``` |
| 84 | + |
| 85 | +## Test Suites |
| 86 | + |
| 87 | +| Suite | Command | Description | |
| 88 | +|-------|---------|-------------| |
| 89 | +| All | `composer test` | Run all tests | |
| 90 | +| Unit | `composer test:unit` | Unit tests only (no API calls) | |
| 91 | +| E2E | `composer test:e2e` | E2E tests (requires env vars) | |
| 92 | + |
| 93 | +## E2E Test Cases |
| 94 | + |
| 95 | +| Test | BMS Type | Description | |
| 96 | +|------|----------|-------------| |
| 97 | +| `testSendBmsTextMinimal` | TEXT | Minimal text message | |
| 98 | +| `testSendBmsTextWithButtons` | TEXT | Text with buttons and coupon | |
| 99 | +| `testSendBmsImage` | IMAGE | Image message | |
| 100 | +| `testSendBmsWide` | WIDE | Wide format message | |
| 101 | +| `testSendBmsCommerce` | COMMERCE | Commerce/product message | |
| 102 | +| `testSendBmsWideItemList` | WIDE_ITEM_LIST | Wide item list (main + 3 sub items) | |
| 103 | +| `testSendBmsCarouselFeed` | CAROUSEL_FEED | Carousel feed message | |
| 104 | +| `testSendBmsCarouselCommerce` | CAROUSEL_COMMERCE | Carousel commerce message | |
| 105 | +| `testSendBmsPremiumVideo` | PREMIUM_VIDEO | Premium video message | |
0 commit comments