php-tmdb / api

PHP 7.3+ API Wrapper for The Movie Database
MIT License
405 stars 112 forks source link

Can't run phpunit locally #141

Closed thinkingmedia closed 7 years ago

thinkingmedia commented 7 years ago

I'm having trouble getting the build or phpunit to work.

Here are my steps:

git clone https://github.com/php-tmdb/api
cd api
composer install -n
vendor/bin/phpunit

The above fails with this error.

PHP Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /api/test/Tmdb/Tests/TestCase.php on line 25

Also, it looks like there is a Phing build script, but Phing is not a dependency. So I tried this

git clone https://github.com/php-tmdb/api
cd api
composer require phing/phing --dev
vendor/bin/phing

Which gives this error.

Buildfile: /api/build.xml

php-tmdb-api > clean:

   [delete] Directory /api/${basedir}/build/api does not exist or is not a directory.
   [delete] Directory /api/${basedir}/build/coverage does not exist or is not a directory.
   [delete] Directory /api/${basedir}/build/logs does not exist or is not a directory.
   [delete] Directory /api/${basedir}/build/pdepend does not exist or is not a directory.

php-tmdb-api > prepare:

    [mkdir] Created dir: /api/${basedir}/build/api
    [mkdir] Created dir: /api/${basedir}/build/coverage
    [mkdir] Created dir: /api/${basedir}/build/logs
    [mkdir] Created dir: /api/${basedir}/build/pdepend
    [mkdir] Created dir: /api/${basedir}/build/phpdox

php-tmdb-api > lint:

BUILD FAILED
/api/build.xml:38:38: phing.types.FileSet doesn't support the 'modified' creator/adder.

Total time: 0.8931 seconds

I can't figure out why Travis can run the tests and I can't.

wtfzdotnet commented 7 years ago
dev ~/test  git clone https://github.com/php-tmdb/api
Cloning into 'api'...
remote: Counting objects: 8113, done.
remote: Total 8113 (delta 0), reused 0 (delta 0), pack-reused 8113
Receiving objects: 100% (8113/8113), 1.49 MiB | 1.47 MiB/s, done.
Resolving deltas: 100% (5492/5492), done.
Checking connectivity... done.
dev ~/test  cd api
dev api 2.1 ✓ composer install -n
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing psr/log (1.0.2)
    Loading from cache

  - Installing guzzlehttp/promises (v1.3.1)
    Loading from cache

  - Installing psr/http-message (1.0.1)
    Loading from cache

  - Installing guzzlehttp/psr7 (1.3.1)
    Loading from cache

  - Installing guzzlehttp/guzzle (6.2.2)
    Loading from cache

  - Installing rtheunissen/guzzle-log-middleware (v0.4.0)
    Loading from cache

  - Installing symfony/event-dispatcher (v3.2.4)
    Loading from cache

  - Installing symfony/options-resolver (v3.2.4)
    Loading from cache

  - Installing doctrine/cache (v1.6.1)
    Loading from cache

  - Installing kevinrob/guzzle-cache-middleware (v1.5.2)
    Loading from cache

  - Installing symfony/yaml (v3.2.4)
    Downloading: 100%         

  - Installing sebastian/version (2.0.1)
    Loading from cache

  - Installing sebastian/resource-operations (1.0.0)
    Downloading: 100%         

  - Installing sebastian/recursion-context (2.0.0)
    Loading from cache

  - Installing sebastian/object-enumerator (2.0.0)
    Loading from cache

  - Installing sebastian/global-state (1.1.1)
    Downloading: 100%         

  - Installing sebastian/exporter (2.0.0)
    Loading from cache

  - Installing sebastian/environment (2.0.0)
    Loading from cache

  - Installing sebastian/diff (1.4.1)
    Downloading: 100%         

  - Installing sebastian/comparator (1.2.4)
    Downloading: Connecting...
    Downloading: 100%         

  - Installing doctrine/instantiator (1.0.5)
    Downloading: 100%         

  - Installing phpunit/php-text-template (1.2.1)
    Downloading: 100%         

  - Installing phpunit/phpunit-mock-objects (3.4.3)
    Loading from cache

  - Installing phpunit/php-timer (1.0.8)
    Loading from cache

  - Installing phpunit/php-file-iterator (1.4.2)
    Loading from cache

  - Installing sebastian/code-unit-reverse-lookup (1.0.0)
    Downloading: 100%         

  - Installing phpunit/php-token-stream (1.4.9)
    Loading from cache

  - Installing phpunit/php-code-coverage (4.0.5)
    Loading from cache

  - Installing webmozart/assert (1.2.0)
    Loading from cache

  - Installing phpdocumentor/reflection-common (1.0)
    Loading from cache

  - Installing phpdocumentor/type-resolver (0.2.1)
    Loading from cache

  - Installing phpdocumentor/reflection-docblock (3.1.1)
    Loading from cache

  - Installing phpspec/prophecy (v1.6.2)
    Loading from cache

  - Installing myclabs/deep-copy (1.6.0)
    Loading from cache

  - Installing phpunit/phpunit (5.7.13)
    Downloading: 100%         

  - Installing monolog/monolog (1.22.0)
    Loading from cache

symfony/event-dispatcher suggests installing symfony/dependency-injection ()
symfony/event-dispatcher suggests installing symfony/http-kernel ()
kevinrob/guzzle-cache-middleware suggests installing league/flysystem (To be use with Kevinrob\GuzzleCache\Storage\FlysystemStorage)
kevinrob/guzzle-cache-middleware suggests installing psr/cache (To be use with Kevinrob\GuzzleCache\Storage\Psr6CacheStorage)
kevinrob/guzzle-cache-middleware suggests installing laravel/framework (To be use with Kevinrob\GuzzleCache\Storage\LaravelCacheStorage)
symfony/yaml suggests installing symfony/console (For validating YAML files using the lint command)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/phpunit-mock-objects suggests installing ext-soap (*)
phpunit/php-code-coverage suggests installing ext-xdebug (>=2.4.0)
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
phpunit/phpunit suggests installing ext-xdebug (*)
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing sentry/sentry (Allow sending log messages to a Sentry server)
Writing lock file
Generating autoload files
dev api 2.1 ✓ vendor/bin/phpunit
PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) 'mbstring.so' in Unknown on line 0

Warning: PHP Startup: Invalid library (maybe not a PHP library) 'mbstring.so' in Unknown on line 0
PHPUnit 5.7.13 by Sebastian Bergmann and contributors.

...............................................................  63 / 438 ( 14%)
............................................................... 126 / 438 ( 28%)
............................................................... 189 / 438 ( 43%)
............................................................... 252 / 438 ( 57%)
............................................................... 315 / 438 ( 71%)
............................................................... 378 / 438 ( 86%)
............................................................    438 / 438 (100%)

Time: 1.08 seconds, Memory: 40.00MB

OK (438 tests, 1731 assertions)
dev api 2.1 ✓ 

Running the exact same script as you provided my output is the above, what php version are you running on?

dev api 2.1 ✓ php -v
PHP 5.6.30-1+deb.sury.org~trusty+1 (cli) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
wtfzdotnet commented 7 years ago
dev api 2.1 ✓ git checkout -b thinkingmedia-thinkingmedia/release_dates 2.1
Switched to a new branch 'thinkingmedia-thinkingmedia/release_dates'
dev api thinkingmedia-thinkingmedia/release_dates ✓ git pull git://github.com/thinkingmedia/api.git thinkingmedia/release_dates
remote: Counting objects: 34, done.
remote: Compressing objects: 100% (21/21), done.
remote: Total 34 (delta 14), reused 7 (delta 7), pack-reused 3
Unpacking objects: 100% (34/34), done.
From git://github.com/thinkingmedia/api
 * branch            thinkingmedia/release_dates -> FETCH_HEAD
Updating 9953812..0cd1596
Fast-forward
 lib/Tmdb/Factory/MovieFactory.php                        |  12 ++++++++++++
 lib/Tmdb/Model/Movie.php                                 |  38 ++++++++++++++++++++++++++++++++++----
 lib/Tmdb/Model/Movie/QueryParameter/AppendToResponse.php |   5 +++++
 lib/Tmdb/Model/Movie/Release.php                         |   1 +
 lib/Tmdb/Model/Movie/ReleaseDate.php                     | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/Tmdb/Repository/MovieRepository.php                  |   2 +-
 test/Tmdb/Tests/Repository/MovieRepositoryTest.php       |   2 +-
 7 files changed, 201 insertions(+), 6 deletions(-)
 create mode 100644 lib/Tmdb/Model/Movie/ReleaseDate.php
dev api thinkingmedia-thinkingmedia/release_dates ✓ vendor/bin/phpunit
PHPUnit 5.7.13 by Sebastian Bergmann and contributors.

...............................................................  63 / 438 ( 14%)
............................................................... 126 / 438 ( 28%)
............................................................... 189 / 438 ( 43%)
............................................................... 252 / 438 ( 57%)
............................................................... 315 / 438 ( 71%)
............................................................... 378 / 438 ( 86%)
............................................................    438 / 438 (100%)

Time: 1.1 seconds, Memory: 40.25MB

OK (438 tests, 1731 assertions)

Seems to do it's job aswell?

wtfzdotnet commented 7 years ago

Noticed this is >= php7 related, I am guessing phpunit switched to a namespaced update and I'll need to constrain the version.

wtfzdotnet commented 7 years ago

See 7b8b757 which restricts the phpunit version for php7

thinkingmedia commented 7 years ago

@wtfzdotnet sorry, I should have mentioned that I was on PHP 7.1.1

Thanks for pushing a fix! 👍

wtfzdotnet commented 7 years ago

The real fix would be migrating the unit tests over to 7 and deprecate 5.6 in the long haul to be honest ;)

Just kind of afraid by doing that the project will lose quite some members.

wtfzdotnet commented 7 years ago

phpunit the php testing framework

thinkingmedia commented 7 years ago

@wtfzdotnet I don't know anyone using PHPUnit 6 right now.

I would stay with what you have and not worry about it. We'll need to update the unit tests to remove any deprecated mock object features.

I'm under the impression that PhpUnit 6 is backward compatible with 5.7. The only breaking change is the use of namespaces.

wtfzdotnet commented 7 years ago

Yeah something to review later on, not something I have time for to dive into within a short amount of time.

Think the correct way to go is to make sure it's done before 5.6 is EOL

thinkingmedia commented 7 years ago

I'm on the CakePHP team, and they've been working to add dual 5.6/6.0 support via aliases. So far it looks like it's working. I can open a PR that does the same thing, but to be honest I'm not in any hurry for to use 6.0. There are still bugs in PhpStorm when using 6.0. So I've been using your fix on some of my other projects to lock it into 5.7