Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ackintosh
Copy link
Contributor

@ackintosh ackintosh commented May 1, 2022

ユニットテストが(CIやローカル環境含め)実行できなくなっていたのを修正しました 🚀

いくつか原因があったので、各コミットログに詳細を書いています 🙏

指定しないと、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.
@ackintosh
Copy link
Contributor Author

PHP 7.3 でテストが実行できない

https://github.com/pepabo/colormeshop-wp-plugin/runs/6247837570?check_suite_focus=true

Composer detected issues in your platform:

Your Composer dependencies require a PHP version ">= 7.4.0". You are running 7.3.33-1+ubuntu20.04.1+deb.sury.org+1.

なるほどたしかに composer.json では platform7.4 を指定しているので矛盾してしまっている 👀

@ackintosh
Copy link
Contributor Author

ackintosh commented May 1, 2022

これって、PHP 7.3で動いている WordPress ではプラグインが動かないということなのだろうか??

PHP 7.3 以上をサポートしているので、platform の指定を 7.3 にした方が良い?

@ackintosh
Copy link
Contributor Author

cc: @milkcaramel @kenchan

@kenchan
Copy link
Contributor

kenchan commented May 11, 2022

#135 これでPHP 7.3にあげていたのですが、なんで7.3でいいと判断したのかがコメントに残ってないですね。

https://ja.wordpress.org/about/requirements/ ここをみて、当時7.3だったらから7.3にしたような朧げな記憶はあります。

今見ると7.4なので、このプラグインのサポートも7.4にして、メジャーバージョンを上げましょうか。

@ackintosh ackintosh marked this pull request as ready for review May 11, 2022 14:45
@ackintosh
Copy link
Contributor Author

ackintosh commented May 13, 2022

ローカルのテストも動くようになったことを確認しました 🙆‍♂️

# 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)

@ackintosh
Copy link
Contributor Author

レビューのほどお願いいたします 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants