From bee2265fc66b1e82c42436de96357387ebee1385 Mon Sep 17 00:00:00 2001 From: "ry.yamafuji" Date: Sun, 17 Nov 2024 21:40:33 +0900 Subject: [PATCH] =?UTF-8?q?php=E3=83=87=E3=83=90=E3=83=83=E3=82=B0?= =?UTF-8?q?=E7=92=B0=E5=A2=83=E6=A7=8B=E7=AF=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 89 ++++++++++++++++++++++++++++++++++++ README.md | 15 ++++++ docker/Dockerfile | 5 ++ src/app/classes/TestCase.php | 9 ++++ src/index.php | 62 +++++++++++++++++++++++-- 5 files changed, 175 insertions(+), 5 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 src/app/classes/TestCase.php diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..2c7a8c4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,89 @@ +{ + "intelephense.environment.phpVersion": "7.4.19", + "intelephense.stubs": [ + "apache", + "bcmath", + "bz2", + "calendar", + "com_dotnet", + "Core", + "ctype", + "curl", + "date", + "dba", + "dom", + "enchant", + "exif", + "FFI", + "fileinfo", + "filter", + "fpm", + "ftp", + "gd", + "gettext", + "gmp", + "hash", + "iconv", + "imap", + "intl", + "json", + "ldap", + "libxml", + "mbstring", + "meta", + "mysqli", + "oci8", + "odbc", + "openssl", + "pcntl", + "pcre", + "PDO", + "pdo_ibm", + "pdo_mysql", + "pdo_pgsql", + "pdo_sqlite", + "pgsql", + "Phar", + "posix", + "pspell", + "random", + "readline", + "Reflection", + "session", + "shmop", + "SimpleXML", + "snmp", + "soap", + "sockets", + "sodium", + "SPL", + "sqlite3", + "standard", + "superglobals", + "sysvmsg", + "sysvsem", + "sysvshm", + "tidy", + "tokenizer", + "xml", + "xmlreader", + "xmlrpc", + "xmlwriter", + "xsl", + "Zend OPcache", + "zip", + "zlib", + "yaml" + ], + "intelephense.phpdoc.classTemplate": { + + "summary": "$1", + "tags": [ + "@package ${1:$SYMBOL_NAMESPACE}" + ] + }, + "php.stubs": [ + "*", + "yaml" + ] +} \ No newline at end of file diff --git a/README.md b/README.md index a4f76c6..bcaf2e8 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,18 @@ lisence : MIT * OpenAPIを読み込みMD形式のテストケースに変換する * YAMLファイルを読み込む機能 + + +## init + +``` +docker-compose up -d --build +docker exec -it php-xdebug bash +``` + +## exec + + +``` +php index.php +``` diff --git a/docker/Dockerfile b/docker/Dockerfile index ee9d727..4ae1e1b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,6 +2,7 @@ FROM php:7.4-apache RUN apt-get update && apt-get install -y \ + libyaml-dev \ vim \ zip \ unzip @@ -10,7 +11,11 @@ RUN apt-get update && apt-get install -y \ RUN cd /usr/bin && curl -s http://getcomposer.org/installer | php && ln -s /usr/bin/composer.phar /usr/bin/composer + # install xdebug RUN pecl install xdebug-2.9.8 \ && docker-php-ext-enable xdebug +# install yaml +RUN pecl install yaml \ + && docker-php-ext-enable yaml diff --git a/src/app/classes/TestCase.php b/src/app/classes/TestCase.php new file mode 100644 index 0000000..56f0204 --- /dev/null +++ b/src/app/classes/TestCase.php @@ -0,0 +1,9 @@ + $data){ + // パラメータのテストケース + + // echo 'openapi='.$yaml['openapi'].PHP_EOL; + + // getの場合のテストケース + // echo 'openapi='.$yaml['openapi'].PHP_EOL; + + // post・putの場合のテストケース + // echo 'openapi='.$yaml['openapi'].PHP_EOL; + + // deleteの場合のテストケース + + break; + } + + + +# echo 'path='.$yaml['paths'][0][0].PHP_EOL; + echo '-------------------------------'.PHP_EOL; + return ; +} + $filename = 'openapi.yaml'; +$yaml = yaml_parse_file($filename); +if(!$yaml){ + print 'ERROR Purse OpenApiFile'.PHP_EOL ; + return -1; +} - -$input = file_get_contents($filename); -$result = \Symfony\Component\Yaml\Yaml::parse($input); - +set_yaml2testcase($yaml); $timer_end = microtime(true);// 実行終了速度 $timer = $timer_end - $timer_start; -echo '実行速度:'.ceil($timer*1000)."ms: $timer"; \ No newline at end of file +echo '実行速度:'.ceil($timer*1000)."ms: $timer".PHP_EOL; \ No newline at end of file