---
name: valec3/backend-testing-integration
source: https://app.decimal.ai/s/valec3-backend-testing-integration@1/SKILL.md
source_sha256: 90d023e4f7a7
---

# Backend Testing Integration

## When to use this skill
- Testing with database
- API endpoint testing
- Feature testing
- End-to-end flows

## Workflow
- [ ] Use test database
- [ ] Seed data
- [ ] Test full flows
- [ ] Reset database
- [ ] Test API responses

## Instructions

### Database Test
```php
<?php

namespace Tests\Integration;

use CodeIgniter\Test\CIDatabaseTestCase;

class UserModelTest extends CIDatabaseTestCase
{
    protected $seed = 'TestSeeder';
    protected $basePath = 'tests/database';

    public function testFindUserByEmail()
    {
        $model = new UserModel();
        $user = $model->where('email', 'test@example.com')->first();

        $this->assertNotNull($user);
        $this->assertEquals('test@example.com', $user->email);
    }
}
```

### Feature Test
```php
<?php

$result = $this->withHeaders(['Authorization' => 'Bearer ' . $token])
    ->post('/api/users', ['name' => 'John'])
    ->json();

$this->assertEquals(201, $result->getStatusCode());
```

## Resources
- Use separate test database
- Seed fixtures
- Test full request/response