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

json_decode() does not work with --json option (invalid JSON format) #5023

Closed
mycarrysun opened this issue Jun 15, 2018 · 1 comment
Closed

Comments

@mycarrysun
Copy link
Contributor

mycarrysun commented Jun 15, 2018

What are you trying to achieve?

I'm trying to save the output to report.json as described by the --json option.
I would like to see something like this as the output:

[{
    "event": "suiteStart",
    "suite": "acceptance",
    "tests": 1
},{
    "event": "testStart",
    "suite": "acceptance",
    "test": "BasicCest: Try to test"
},{
    "event": "test",
    "suite": "acceptance",
    "test": "BasicCest: Try to test",
    "status": "pass",
    "time": 8.1775150299072,
    "trace": [],
    "message": "",
    "output": ""
}]

so that json_decode(file_get_contents('path/to/report.json')) will parse the JSON correctly.

What do you get instead?

The output JSON is not correctly formatted. It is missing the opening and closing bracket and the commas between event objects.

{
    "event": "suiteStart",
    "suite": "acceptance",
    "tests": 1
}{
    "event": "testStart",
    "suite": "acceptance",
    "test": "BasicCest: Try to test"
}{
    "event": "test",
    "suite": "acceptance",
    "test": "BasicCest: Try to test",
    "status": "pass",
    "time": 8.1775150299072,
    "trace": [],
    "message": "",
    "output": ""
}

Provide console output if related. Use -vvv mode for more details.

Codeception PHP Testing Framework v2.4.1
Powered by PHPUnit 6.5.8 by Sebastian Bergmann and contributors.

Acceptance Tests (1) -----------------------------------------------------------
✔ BasicCest: Try to test (3.61s)
--------------------------------------------------------------------------------


Time: 3.82 seconds, Memory: 22.00MB

OK (1 test, 12 assertions)
- JSON report generated in file:///home/*********/dev/api/tests/_output/report.json

Details

  • Codeception version: 2.4.1
  • PHP Version: 7.0
  • Operating System: CentOS 7
  • Installation type: Composer
  • List of installed packages
aws/aws-sdk-php                            3.54.4       AWS SDK for PHP - Use Amazon Web Services in your PHP project
barryvdh/laravel-cors                      v0.9.3       Adds CORS (Cross-Origin Resource Sharing) headers support in your L...
barryvdh/laravel-ide-helper                v2.4.3       Laravel IDE Helper, generates correct PHPDocs for all Facade classe...
barryvdh/reflection-docblock               v2.0.4
behat/gherkin                              v4.5.1       Gherkin DSL parser for PHP 5.3
codeception/codeception                    2.4.1        BDD-style testing framework
codeception/phpunit-wrapper                6.0.9        PHPUnit classes used by Codeception
codeception/stub                           1.0.2        Flexible Stub wrapper for PHPUnit's Mock Builder
codedge/laravel-fpdf                       1.2.3        Laravel 5 package for use with Fpdf. It ships with Fpdf 1.81.
dingo/api                                  v1.0.0-beta8 A RESTful API package for the Laravel and Lumen frameworks.
dingo/blueprint                            v0.2.4       API Blueprint documentation generator.
dnoegel/php-xdg-base-dir                   0.1          implementation of xdg base directory specification for php
doctrine/annotations                       v1.4.0       Docblock Annotations Parser
doctrine/cache                             v1.6.2       Caching library offering an object-oriented API for many cache back...
doctrine/collections                       v1.4.0       Collections Abstraction library
doctrine/common                            v2.7.3       Common Library for Doctrine projects
doctrine/dbal                              v2.5.13      Database Abstraction Layer
doctrine/inflector                         v1.2.0       Common String Manipulations with regard to casing and singular/plur...
doctrine/instantiator                      1.0.5        A small, lightweight utility to instantiate objects in PHP without ...
doctrine/lexer                             v1.0.1       Base library for a lexer that can be used in Top-Down, Recursive De...
dompdf/dompdf                              v0.8.2       DOMPDF is a CSS 2.1 compliant HTML to PDF converter
erusev/parsedown                           1.7.1        Parser for Markdown.
facebook/webdriver                         1.5.0        A PHP client for Selenium WebDriver
fzaninotto/faker                           v1.7.1       Faker is a PHP library that generates fake data for you.
guzzlehttp/guzzle                          6.3.2        Guzzle is a PHP HTTP client library
guzzlehttp/promises                        v1.3.1       Guzzle promises library
guzzlehttp/psr7                            1.4.2        PSR-7 message implementation that also provides common utility methods
hamcrest/hamcrest-php                      v1.2.2       This is the PHP port of Hamcrest Matchers
hps/heartland-php                          v2.12.1      PHP SDK for processing payments via Portico Gateway
jakub-onderka/php-console-color            0.1
jakub-onderka/php-console-highlighter      v0.3.2
jeremeamia/SuperClosure                    2.4.0        Serialize Closure objects, including their context and binding
joomla-projects/selenium-server-standalone v3.11.0.4    Composer distribution of Selenium Server Standalone, the browser au...
lanin/laravel-api-debugger                 3.1.0        Easily debug your JSON API.
laravel/framework                          v5.4.36      The Laravel Framework.
laravel/tinker                             v1.0.6       Powerful REPL for the Laravel framework.
lcobucci/jwt                               3.2.2        A simple library to work with JSON Web Token and JSON Web Signature
league/flysystem                           1.0.44       Filesystem abstraction: Many filesystems, one API.
league/flysystem-aws-s3-v3                 1.0.19       Flysystem adapter for the AWS S3 SDK v3.x
league/fractal                             0.17.0       Handle the output of complex data structures ready for API output.
maatwebsite/excel                          2.1.27       An eloquent way of importing and exporting Excel and CSV in Laravel...
mikehaertl/php-pdftk                       0.4.4        A PDF conversion and form utility based on pdftk.
mikehaertl/php-shellcommand                1.4.0        An object oriented interface to shell commands
mikehaertl/php-tmpfile                     1.1.1        A convenience class for temporary files
mockery/mockery                            0.9.9        Mockery is a simple yet flexible PHP mock object framework for use ...
monolog/monolog                            1.23.0       Sends your logs to files, sockets, inboxes, databases and various w...
mtdowling/cron-expression                  v1.2.1       CRON for PHP: Calculate the next or previous run date and determine...
mtdowling/jmespath.php                     2.4.0        Declaratively specify how to extract elements from a JSON document
myclabs/deep-copy                          1.7.0        Create deep copies (clones) of your objects
namshi/jose                                7.2.3        JSON Object Signing and Encryption library for PHP.
nesbot/carbon                              1.26.4       A simple API extension for DateTime.
nikic/php-parser                           v4.0.1       A PHP parser written in PHP
paragonie/random_compat                    v2.0.12      PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
phar-io/manifest                           1.0.1        Component for reading phar.io manifest information from a PHP Archi...
phar-io/version                            1.0.1        Library for handling version information and constraints
phenx/php-font-lib                         0.5.1        A library to read, parse, export and make subsets of different type...
phenx/php-svg-lib                          v0.3         A library to read, parse and export to PDF SVG files.
phpdocumentor/reflection-common            1.0.1        Common reflection classes used by phpdocumentor to reflect the code...
phpdocumentor/reflection-docblock          3.3.2        With this component, a library can provide support for annotations ...
phpdocumentor/type-resolver                0.4.0
phpoffice/phpexcel                         1.8.1        PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents i...
phpspec/prophecy                           1.7.6        Highly opinionated mocking framework for PHP 5.3 
phpunit/php-code-coverage                  5.3.2        Library that provides collection, processing, and rendering functio...
phpunit/php-file-iterator                  1.4.5        FilterIterator implementation that filters files based on a list of...
phpunit/php-text-template                  1.2.1        Simple template engine.
phpunit/php-timer                          1.0.9        Utility class for timing
phpunit/php-token-stream                   2.0.2        Wrapper around PHP's tokenizer extension.
phpunit/phpunit                            6.5.8        The PHP Unit Testing framework.
phpunit/phpunit-mock-objects               5.0.6        Mock Object library for PHPUnit
psr/http-message                           1.0.1        Common interface for HTTP messages
psr/log                                    1.0.2        Common interface for logging libraries
psy/psysh                                  v0.9.3       An interactive shell for modern PHP.
ramsey/uuid                                3.7.3        Formerly rhumsaa/uuid. A PHP 5.4  library for generating RFC 4122 v...
sabberworm/php-css-parser                  8.1.0        Parser for CSS Files written in PHP
se/selenium-server-standalone              3.11.0       Composer distribution of Selenium Server Standalone, the browser au...
sebastian/code-unit-reverse-lookup         1.0.1        Looks up which function or method a line of code belongs to
sebastian/comparator                       2.1.3        Provides the functionality to compare PHP values for equality
sebastian/diff                             2.0.1        Diff implementation
sebastian/environment                      3.1.0        Provides functionality to handle HHVM/PHP environments
sebastian/exporter                         3.1.0        Provides the functionality to export PHP variables for visualization
sebastian/global-state                     2.0.0        Snapshotting of global state
sebastian/object-enumerator                3.0.3        Traverses array structures and object graphs to enumerate all refer...
sebastian/object-reflector                 1.1.1        Allows reflection of object attributes, including inherited and non...
sebastian/recursion-context                3.0.0        Provides functionality to recursively process PHP variables
sebastian/resource-operations              1.0.0        Provides a list of PHP built-in functions that operate on resources
sebastian/version                          2.0.1        Library that helps with managing the version number of Git-hosted P...
sentry/sentry                              1.8.4        A PHP client for Sentry (http://getsentry.com)
sentry/sentry-laravel                      0.8.0        Laravel integration for Sentry (https://sentry.io)
swiftmailer/swiftmailer                    v5.4.9       Swiftmailer, free feature-rich PHP mailer
symfony/browser-kit                        v3.4.9       Symfony BrowserKit Component
symfony/class-loader                       v3.4.8       Symfony ClassLoader Component
symfony/console                            v3.4.8       Symfony Console Component
symfony/css-selector                       v3.4.8       Symfony CssSelector Component
symfony/debug                              v3.4.8       Symfony Debug Component
symfony/dom-crawler                        v3.4.9       Symfony DomCrawler Component
symfony/event-dispatcher                   v3.4.8       Symfony EventDispatcher Component
symfony/finder                             v3.4.8       Symfony Finder Component
symfony/http-foundation                    v3.4.8       Symfony HttpFoundation Component
symfony/http-kernel                        v3.4.8       Symfony HttpKernel Component
symfony/polyfill-iconv                     v1.7.0       Symfony polyfill for the Iconv extension
symfony/polyfill-mbstring                  v1.7.0       Symfony polyfill for the Mbstring extension
symfony/polyfill-php56                     v1.7.0       Symfony polyfill backporting some PHP 5.6  features to lower PHP ve...
symfony/polyfill-php70                     v1.7.0       Symfony polyfill backporting some PHP 7.0  features to lower PHP ve...
symfony/polyfill-util                      v1.7.0       Symfony utilities for portability of PHP codes
symfony/process                            v3.4.8       Symfony Process Component
symfony/routing                            v3.4.8       Symfony Routing Component
symfony/translation                        v3.4.8       Symfony Translation Component
symfony/var-dumper                         v3.4.8       Symfony mechanism for exploring and dumping PHP variables
symfony/yaml                               v3.4.9       Symfony Yaml Component
theseer/tokenizer                          1.1.0        A small library for converting tokenized PHP source code into XML a...
tijsverkoyen/css-to-inline-styles          2.2.1        CssToInlineStyles is a class that enables you to convert HTML-pages...
tymon/jwt-auth                             1.0.0-rc.2   JSON Web Token Authentication for Laravel and Lumen
vlucas/phpdotenv                           v2.4.0       Loads environment variables from `.env` to `getenv()`, `$_ENV` and ...
webmozart/assert                           1.3.0        Assertions to validate method input/output with nice error messages.
  • Suite configuration:
# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.

actor: AcceptanceTester
modules:
    enabled:
        - \Helper\Acceptance
        - PhpBrowser:
            url: 'https://google.com'
            allow_redirects: true
        - Laravel5:
            environment_file: .env
            part: ORM
            cleanup: false
                    
@mycarrysun
Copy link
Contributor Author

Fixed in #34

DavertMik pushed a commit that referenced this issue Jun 20, 2018
* Created failing test RunCest::runJsonReport

* PSR2 Formatting

* Removed double parentheses
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

No branches or pull requests

1 participant