-
Notifications
You must be signed in to change notification settings - Fork 5
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
ユニットテストが実行できないのを修正 #157
base: master
Are you sure you want to change the base?
ユニットテストが実行できないのを修正 #157
Conversation
指定しないと、composerのDockerイメージで `composer install` を実行したときに下記のエラーが起きてしまう。 (ただし、--no-dev オプションをつけると発生しない) Problem 1 - phpdocumentor/reflection-docblock is locked to version 5.1.0 and an update of this package was not requested. - phpdocumentor/reflection-docblock 5.1.0 requires ext-filter ^7.1 -> it has the wrong version installed (8.1.5). Problem 2 - phpdocumentor/reflection-docblock 5.1.0 requires ext-filter ^7.1 -> it has the wrong version installed (8.1.5). - phpspec/prophecy v1.10.3 requires phpdocumentor/reflection-docblock ^2.0|^3.0.2|^4.0|^5.0 -> satisfiable by phpdocumentor/reflection-docblock[5.1.0]. - phpspec/prophecy is locked to version v1.10.3 and an update of this package was not requested.
当該プラグインのドキュメント: https://github.com/PHPCSStandards/composer-installer#usage > When using Composer 2.2 or higher, Composer will ask for your permission to allow this plugin to execute code.
PHP 7.3 でテストが実行できないhttps://github.com/pepabo/colormeshop-wp-plugin/runs/6247837570?check_suite_focus=true
なるほどたしかに composer.json では |
これって、PHP 7.3で動いている WordPress ではプラグインが動かないということなのだろうか?? PHP 7.3 以上をサポートしているので、 |
cc: @milkcaramel @kenchan |
#135 これでPHP 7.3にあげていたのですが、なんで7.3でいいと判断したのかがコメントに残ってないですね。 https://ja.wordpress.org/about/requirements/ ここをみて、当時7.3だったらから7.3にしたような朧げな記憶はあります。 今見ると7.4なので、このプラグインのサポートも7.4にして、メジャーバージョンを上げましょうか。 |
ローカルのテストも動くようになったことを確認しました 🙆♂️ # Dockerfileを調整したので再ビルド
$ docker-compose build
# 動作確認
$ ./tests/run.sh
[+] Running 2/0
⠿ Container colormeshop-wp-plugin-mysql-1 Running 0.0s
⠿ Container colormeshop-wp-plugin-composer-1 Created 0.0s
[+] Running 1/1
⠿ Container colormeshop-wp-plugin-composer-1 Started 0.3s
+ install_wp
+ '[' -d /tmp/wordpress/ ']'
+ mkdir -p /tmp/wordpress/
+ [[ latest == \n\i\g\h\t\l\y ]]
+ [[ latest == \t\r\u\n\k ]]
+ '[' latest == latest ']'
+ local ARCHIVE_NAME=latest
+ download https://wordpress.org/latest.tar.gz /tmp/wordpress.tar.gz
++ which curl
+ '[' /usr/bin/curl ']'
+ curl -s https://wordpress.org/latest.tar.gz
+ tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C /tmp/wordpress/
+ download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php /tmp/wordpress//wp-content/db.php
++ which curl
+ '[' /usr/bin/curl ']'
+ curl -s https://raw.github.com/markoheijnen/wp-mysqli/master/db.php
+ install_test_suite
++ uname -s
+ [[ Linux == \D\a\r\w\i\n ]]
+ local ioption=-i
+ '[' -d /tmp/wordpress-tests-lib ']'
+ mkdir -p /tmp/wordpress-tests-lib
+ svn co --quiet https://develop.svn.wordpress.org/tags/5.9.3/tests/phpunit/includes/ /tmp/wordpress-tests-lib/includes
+ svn co --quiet https://develop.svn.wordpress.org/tags/5.9.3/tests/phpunit/data/ /tmp/wordpress-tests-lib/data
+ '[' '!' -f wp-tests-config.php ']'
+ download https://develop.svn.wordpress.org/tags/5.9.3/wp-tests-config-sample.php /tmp/wordpress-tests-lib/wp-tests-config.php
++ which curl
+ '[' /usr/bin/curl ']'
+ curl -s https://develop.svn.wordpress.org/tags/5.9.3/wp-tests-config-sample.php
++ echo /tmp/wordpress/
++ sed 's:/\+$::'
+ WP_CORE_DIR=/tmp/wordpress
+ sed -i 's:dirname( __FILE__ ) . '\''/src/'\'':'\''/tmp/wordpress/'\'':' /tmp/wordpress-tests-lib/wp-tests-config.php
+ sed -i s/youremptytestdbnamehere/unit_test/ /tmp/wordpress-tests-lib/wp-tests-config.php
+ sed -i s/yourusernamehere/root/ /tmp/wordpress-tests-lib/wp-tests-config.php
+ sed -i s/yourpasswordhere/example_password/ /tmp/wordpress-tests-lib/wp-tests-config.php
+ sed -i 's|localhost|mysql|' /tmp/wordpress-tests-lib/wp-tests-config.php
+ install_db
+ '[' false = true ']'
+ PARTS=('mysql')
+ local PARTS
+ local DB_HOSTNAME=mysql
+ local DB_SOCK_OR_PORT=
+ local EXTRA=
+ '[' -z mysql ']'
++ echo
++ grep -e '^[0-9]\{1,\}$'
+ '[' ']'
+ '[' -z ']'
+ '[' -z mysql ']'
+ EXTRA=' --host=mysql --protocol=tcp'
+ mysqladmin create unit_test --user=root --password=example_password --host=mysql --protocol=tcp
mysqladmin: CREATE DATABASE failed; error: 'Can't create database 'unit_test'; database exists'
Installing...
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.
................................................................. 65 / 67 ( 97%)
.. 67 / 67 (100%)
Time: 1.86 seconds, Memory: 48.50 MB
OK (67 tests, 86 assertions)
Code Coverage Report:
2022-05-13 13:12:50
Summary:
Classes: 42.86% (6/14)
Methods: 72.09% (62/86)
Lines: 73.40% (345/470)
\ColorMeShop::ColorMeShop\Admin
Methods: 72.73% ( 8/11) Lines: 77.61% ( 52/ 67)
\ColorMeShop::ColorMeShop\Paginator
Methods: 100.00% ( 4/ 4) Lines: 100.00% ( 13/ 13)
\ColorMeShop::ColorMeShop\Paginator_Factory
Methods: 100.00% ( 2/ 2) Lines: 100.00% ( 4/ 4)
\ColorMeShop::ColorMeShop\Plugin
Methods: 33.33% ( 5/15) Lines: 46.10% ( 65/141)
\ColorMeShop::ColorMeShop\Url_Builder
Methods: 100.00% ( 8/ 8) Lines: 100.00% ( 18/ 18)
\ColorMeShop\Api::ColorMeShop\Api\Product_Api
Methods: 28.57% ( 2/ 7) Lines: 85.71% ( 42/ 49)
\ColorMeShop\Models::ColorMeShop\Models\Setting
Methods: 100.00% ( 7/ 7) Lines: 100.00% ( 18/ 18)
\ColorMeShop\Models::ColorMeShop\Models\Sitemap
Methods: 100.00% ( 3/ 3) Lines: 100.00% ( 16/ 16)
\ColorMeShop\Shortcodes::ColorMeShop\Shortcodes\Product
Methods: 100.00% (15/15) Lines: 100.00% ( 37/ 37)
\ColorMeShop\Shortcodes\Cart::ColorMeShop\Shortcodes\Cart\Button
Methods: 50.00% ( 1/ 2) Lines: 69.23% ( 9/ 13)
\ColorMeShop\Shortcodes\Product::ColorMeShop\Shortcodes\Product\Image
Methods: 83.33% ( 5/ 6) Lines: 93.02% ( 40/ 43)
\ColorMeShop\Shortcodes\Product::ColorMeShop\Shortcodes\Product\Option
Methods: 50.00% ( 1/ 2) Lines: 88.46% ( 23/ 26)
\ColorMeShop\Shortcodes\Product::ColorMeShop\Shortcodes\Product\Page
Methods: 50.00% ( 1/ 2) Lines: 40.00% ( 8/ 20) |
レビューのほどお願いいたします 🙏 |
ユニットテストが(CIやローカル環境含め)実行できなくなっていたのを修正しました 🚀
いくつか原因があったので、各コミットログに詳細を書いています 🙏