-
Notifications
You must be signed in to change notification settings - Fork 1
CursorにUnitTestを作らせた #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kaz29
wants to merge
7
commits into
main
Choose a base branch
from
feat/unittest
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a3f1a53
[WIP] CursorでUnitTestを追加してみた
kaz29 92ac21f
fix
kaz29 43b710f
add docker settings for local test
kaz29 6006d4c
add ci workflow
kaz29 392248b
remove unused line
kaz29 747b8e6
add test
kaz29 53d30f8
アトリビュートが正常に生成されているかのテストを追加
kaz29 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
types: [opened, synchronize, reopened] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php-version: ['8.3', '8.4'] | ||
fail-fast: false | ||
|
||
services: | ||
mysql: | ||
image: mysql:8.0 | ||
env: | ||
MYSQL_ROOT_PASSWORD: secret | ||
MYSQL_DATABASE: test_openapi_theme | ||
ports: | ||
- 3306:3306 | ||
options: >- | ||
--health-cmd="mysqladmin ping" | ||
--health-interval=10s | ||
--health-timeout=5s | ||
--health-retries=3 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-version }} | ||
extensions: intl, zip, pdo_mysql | ||
coverage: none | ||
|
||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
||
- name: Cache composer dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
|
||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress | ||
|
||
- name: Wait for MySQL | ||
run: | | ||
while ! mysqladmin ping -h"127.0.0.1" -P"3306" --silent; do | ||
sleep 1 | ||
done | ||
|
||
- name: Run tests | ||
run: vendor/bin/phpunit | ||
env: | ||
DATABASE_URL: mysql://root:[email protected]/test_openapi_theme?encoding=utf8mb4&timezone=UTC&cacheMetadata=true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
/vendor/ | ||
/.idea/ | ||
.DS_Store | ||
/tests/test_app/src/Controller |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
ARG PHP_VERSION | ||
FROM php:${PHP_VERSION}-cli | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
libicu-dev \ | ||
libzip-dev \ | ||
unzip \ | ||
git \ | ||
&& docker-php-ext-install \ | ||
intl \ | ||
zip \ | ||
pdo_mysql | ||
|
||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer | ||
|
||
WORKDIR /app | ||
|
||
CMD ["vendor/bin/phpunit"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
version: '3.8' | ||
|
||
services: | ||
test-php84: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.test | ||
args: | ||
PHP_VERSION: "8.4" | ||
volumes: | ||
- .:/app | ||
depends_on: | ||
- db-test | ||
environment: | ||
- DATABASE_URL=mysql://root:secret@db-test/test_openapi_theme?encoding=utf8mb4&timezone=UTC&cacheMetadata=true | ||
|
||
test-php83: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.test | ||
args: | ||
PHP_VERSION: "8.3" | ||
volumes: | ||
- .:/app | ||
depends_on: | ||
- db-test | ||
environment: | ||
- DATABASE_URL=mysql://root:secret@db-test/test_openapi_theme?encoding=utf8mb4&timezone=UTC&cacheMetadata=true | ||
|
||
db-test: | ||
image: mysql:8.0 | ||
environment: | ||
MYSQL_ROOT_PASSWORD: secret | ||
MYSQL_DATABASE: test_openapi_theme | ||
command: --default-authentication-plugin=mysql_native_password | ||
ports: | ||
- "3306" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
# コンテナをビルド | ||
docker-compose -f docker-compose.test.yml build | ||
|
||
# PHP 8.4でテスト実行 | ||
echo "Running tests with PHP 8.4..." | ||
docker-compose -f docker-compose.test.yml run --rm test-php84 composer install | ||
docker-compose -f docker-compose.test.yml run --rm test-php84 | ||
|
||
# PHP 8.3でテスト実行 | ||
echo "Running tests with PHP 8.3..." | ||
docker-compose -f docker-compose.test.yml run --rm test-php83 composer install | ||
docker-compose -f docker-compose.test.yml run --rm test-php83 | ||
|
||
# コンテナを停止・削除 | ||
docker-compose -f docker-compose.test.yml down |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace OpenApiTheme\Test\Fixture; | ||
|
||
use Cake\TestSuite\Fixture\TestFixture; | ||
|
||
class TestTablesFixture extends TestFixture | ||
{ | ||
/** | ||
* Fields | ||
* | ||
* @var array<string, mixed> | ||
*/ | ||
public array $fields = [ | ||
'id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => 'Primary key', 'autoIncrement' => true], | ||
'name' => ['type' => 'string', 'length' => 255, 'null' => false, 'default' => null, 'comment' => 'Name field', 'collate' => 'utf8mb4_general_ci'], | ||
'created' => ['type' => 'datetime', 'length' => null, 'precision' => null, 'null' => false, 'default' => null, 'comment' => ''], | ||
'modified' => ['type' => 'datetime', 'length' => null, 'precision' => null, 'null' => false, 'default' => null, 'comment' => ''], | ||
'_constraints' => [ | ||
'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []], | ||
], | ||
'_options' => [ | ||
'engine' => 'InnoDB', | ||
'collation' => 'utf8mb4_general_ci' | ||
], | ||
]; | ||
|
||
/** | ||
* Init method | ||
* | ||
* @return void | ||
*/ | ||
public function init(): void | ||
{ | ||
$this->records = [ | ||
[ | ||
'id' => 1, | ||
'name' => 'Test Record', | ||
'created' => '2024-01-01 00:00:00', | ||
'modified' => '2024-01-01 00:00:00' | ||
], | ||
]; | ||
parent::init(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a timeout or maximum number of retries to the MySQL waiting loop to avoid a potential infinite loop if MySQL fails to start.
Copilot uses AI. Check for mistakes.