composer package testing bootstrap

一笑奈何 提交于 2019-12-01 17:55:47

Well, I've figured the answer.
Composer provides it's own autoloader I could use.

  1. Run composer install or composer update in the project root. This will create the vendor dir with composers autoload.php file.
  2. Add vendor dir to .gitignore along with composer.lock
  3. In phpunit.xml.dist specify composer's autoloader as the bootstrap file

Example phpunit.xml.dist file

<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="vendor/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false"
         syntaxCheck="false"
        >

    <testsuites>
        <testsuite name="Your package's test suit">
            <directory>./tests/</directory>
        </testsuite>
    </testsuites>

</phpunit>

Notice the bootstrap entry there.

Yes you should run composer update. It is not harmful to try since everything is put into /vendor/ which you can later delete.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!