Skip to content

Commit cc4eb77

Browse files
Add testing guide and enhance BmsFreeSendTest for image handling
- Introduced a comprehensive testing guide in TESTING.md, detailing test commands, structure, and E2E test configuration. - Updated BmsFreeSendTest to correct image handling by specifying accurate image types for wide item lists.
1 parent 42fd65d commit cc4eb77

2 files changed

Lines changed: 107 additions & 2 deletions

File tree

docs/TESTING.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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 |

tests/E2E/BmsFreeSendTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ public function testSendBmsWideItemList(): void
341341

342342
try {
343343
// Upload main image (2:1 ratio)
344-
$mainImageId = $this->messageService->uploadFile($mainImagePath, 'BMS_WIDE_ITEM_LIST_MAIN');
344+
$mainImageId = $this->messageService->uploadFile($mainImagePath, 'BMS_WIDE_MAIN_ITEM_LIST');
345345
// Upload sub images (1:1 ratio)
346-
$subImageId = $this->messageService->uploadFile($subImagePath, 'BMS_WIDE_ITEM_LIST_SUB');
346+
$subImageId = $this->messageService->uploadFile($subImagePath, 'BMS_WIDE_SUB_ITEM_LIST');
347347

348348
$mainItem = new BmsMainWideItem();
349349
$mainItem->setImageId($mainImageId)

0 commit comments

Comments
 (0)