{"action":"created","issue":{"url":"https://api.github.com/repos/Codeception/Codeception/issues/4942","repository_url":"https://api.github.com/repos/Codeception/Codeception","labels_url":"https://api.github.com/repos/Codeception/Codeception/issues/4942/labels{/name}","comments_url":"https://api.github.com/repos/Codeception/Codeception/issues/4942/comments","events_url":"https://api.github.com/repos/Codeception/Codeception/issues/4942/events","html_url":"https://github.com/Codeception/Codeception/issues/4942","id":315037349,"number":4942,"title":"Response is null for json format","user":{"login":"amarox","id":2937969,"avatar_url":"https://avatars3.githubusercontent.com/u/2937969?v=4","gravatar_id":"","url":"https://api.github.com/users/amarox","html_url":"https://github.com/amarox","followers_url":"https://api.github.com/users/amarox/followers","following_url":"https://api.github.com/users/amarox/following{/other_user}","gists_url":"https://api.github.com/users/amarox/gists{/gist_id}","starred_url":"https://api.github.com/users/amarox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amarox/subscriptions","organizations_url":"https://api.github.com/users/amarox/orgs","repos_url":"https://api.github.com/users/amarox/repos","events_url":"https://api.github.com/users/amarox/events{/privacy}","received_events_url":"https://api.github.com/users/amarox/received_events","type":"User","site_admin":false},"labels":[{"id":31385312,"url":"https://api.github.com/repos/Codeception/Codeception/labels/Yii","name":"Yii","color":"bdc3c7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-17T12:29:04Z","updated_at":"2018-05-10T14:13:58Z","closed_at":null,"author_association":"NONE","body":"#### What are you trying to achieve?\r\ntesting rest action for Yii2\r\n\r\n#### What do you get instead?\r\n\r\n> Provide console output if related. Use `-vvv` mode for more details.\r\n\r\n```bash\r\nrun functional BasketCest -c frontend --debug\r\nCannot load Xdebug - it was already loaded\r\nCodeception PHP Testing Framework v2.4.1\r\nPowered by PHPUnit 7.1.2 by Sebastian Bergmann and contributors.\r\n\r\nFrontend\\tests.functional Tests (1) --------------------------------------------\r\nModules: \\frontend\\tests\\Helper\\Functional, Filesystem, Yii2, REST\r\n--------------------------------------------------------------------------------\r\nBasketCest: Try add to basket\r\nSignature: frontend\\tests\\functional\\BasketCest:tryAddToBasket\r\nTest: tests/functional/BasketCest.php:tryAddToBasket\r\nScenario --\r\n  Destroying application\r\n  Starting application\r\n  [Fixtures] Loading fixtures\r\n  [Fixtures] Done\r\n I grab record \"modules\\catalog\\models\\Product\",{\"id\":1}\r\n  [yii\\db\\Connection::open] 'Opening DB connection: mysql:host=mariadb;dbname=test'\r\n  [Database] Transaction started for: mysql:host=mariadb;dbname=test\r\n I am on route \"online-shop/product\",{\"slug\":\"mokasiny-zenskie-respect\",\"id\":1}\r\n  [Request Headers] []\r\n  [yii\\web\\Session::open] 'Session started'\r\n  \r\n  [Page] /detail/mokasiny-zenskie-respect-1/\r\n  [Response] 200\r\n  [Request Cookies] []\r\n  [Response Headers] []\r\n I see response code is 200\r\n I send get \"shop/basket/add/\",{\"product_id\":1,\"offer_id\":15,\"link\":\"/link-u...}\r\n  [Request] GET /shop/basket/add/?product_id=1&offer_id=15&link=%2Flink-url\r\n  [Request Headers] []\r\n  \r\n  [Page] /shop/basket/add/?product_id=1&offer_id=15&link=%2Flink-url\r\n  [Response] 200\r\n  [Request Cookies] {\"_csrf\":\"8e1e478c17d49a52accfa311f1939fe203570ea63bbeb6b498264a84e0a03f98a:2:{i:0;s:5:\"_csrf\";i:1;s:32:\"p3pAG55sLq2g060WgBqedyzFj-qT_lc4\";}\"}\r\n  [Response Headers] []\r\n  [Response] \r\n I see response code is 200\r\n I see response is json \r\n FAIL \r\n\r\n  [Database] Transaction cancelled; all changes reverted.\r\n  Suite done, restoring $_SERVER to original\r\n--------------------------------------------------------------------------------\r\n\r\n\r\nTime: 1.94 seconds, Memory: 20.00MB\r\n\r\nThere was 1 failure:\r\n\r\n---------\r\n1) BasketCest: Try add to basket\r\n Test  tests/functional/BasketCest.php:tryAddToBasket\r\n Step  See response is json \r\n Fail  response is empty\r\nFailed asserting that '' is not equal to \"\".\r\n\r\nScenario Steps:\r\n\r\n 6. $I->seeResponseIsJson() at tests/functional/BasketCest.php:34\r\n 5. $I->seeResponseCodeIs(200) at tests/functional/BasketCest.php:33\r\n 4. $I->sendGET(\"shop/basket/add/\",{\"product_id\":1,\"offer_id\":15,\"link\":\"/l...}) at tests/functional/BasketCest.php:31\r\n 3. $I->seeResponseCodeIs(200) at tests/functional/BasketCest.php:27\r\n 2. $I->amOnRoute(\"online-shop/product\",{\"slug\":\"mokasiny-zenskie-respect\",...}) at tests/functional/BasketCest.php:25\r\n 1. $I->grabRecord(\"modules\\catalog\\models\\Product\",{\"id\":1}) at tests/functional/BasketCest.php:22\r\n\r\n\r\nFAILURES!\r\nTests: 1, Assertions: 3, Failures: 1.\r\n  Destroying application\r\n\r\n```\r\n> Provide test source code if related\r\n\r\n```php\r\n$product = $I->grabRecord(Product::class, ['id' => 1]);\r\n        $I->amOnRoute('online-shop/product', [\r\n            'slug' => $product->slug,\r\n            'id' => $product->id\r\n        ]);\r\n        $I->seeResponseCodeIs(200);\r\n        $I->sendGET(\"shop/basket/add/\", [\r\n            'product_id' => $product->id,\r\n            'offer_id' => 15,\r\n            'link' => \"/link-url/fuck\",\r\n        ]);\r\n        $I->seeResponseCodeIs(200);\r\n        $I->seeResponseIsJson();\r\n```\r\n### Details\r\n\r\n* Codeception version: 2.4.1\r\n* PHP Version: 7.2.1\r\n* Operating System: Debian\r\n* Installation type: Composer\r\n* List of installed packages (`composer show`)\r\namarox/assets-builder                 0.5.2              Php assets build system\r\nbehat/gherkin                         v4.5.1             Gherkin DSL parser for PHP 5.3\r\nbower-asset/admin-lte                 v2.3.11           \r\nbower-asset/autonumeric               1.9.46            \r\nbower-asset/backbone                  1.3.3             \r\nbower-asset/backbone.localstorage     2.0.0             \r\nbower-asset/bootstrap                 v3.3.7            \r\nbower-asset/bootstrap-daterangepicker v2.1.27           \r\nbower-asset/bootstrap-less            3.3.4             \r\nbower-asset/bootstrap-select          v1.11.2           \r\nbower-asset/bootstrap3-dialog         v1.35.4           \r\nbower-asset/font-awesome              5.0.8             \r\nbower-asset/fontawesome               v4.7.0            \r\nbower-asset/inputmask                 3.3.11            \r\nbower-asset/jquery                    2.2.4             \r\nbower-asset/jquery-pjax               v2.0.1            \r\nbower-asset/jquery-treegrid           0.3.0             \r\nbower-asset/jquery-ui                 1.12.1            \r\nbower-asset/jquery.cookie             v1.4.1            \r\nbower-asset/jquery.scrollto           2.1.2             \r\nbower-asset/moment                    2.21.0            \r\nbower-asset/normalize-less            dev-master cf34639\r\nbower-asset/owl.carousel              2.3.2             \r\nbower-asset/punycode                  v1.3.2            \r\nbower-asset/typeahead.js              v0.11.1           \r\nbower-asset/underscore                1.8.3             \r\nbower-asset/x-editable                1.5.1             \r\nbower-asset/yii2-pjax                 2.0.7.1           \r\ncebe/markdown                         1.1.2              A super fast, highly extensible markdown parser for PHP\r\ncodeception/base                      2.4.1              BDD-style testing framework\r\ncodeception/phpunit-wrapper           7.1.0              PHPUnit classes used by Codeception\r\ncodeception/specify                   1.1                BDD code blocks for PHPUnit and Codeception\r\ncodeception/stub                      1.0.2              Flexible Stub wrapper for PHPUnit's Mock Builder\r\ncodeception/verify                    1.0.0              BDD assertion library for PHPUnit\r\ncomponents/backbone                   1.2.0              Give your JS App some Backbone with Models, Views, Collections, and Events.\r\ncomponents/underscore                 1.8.3              JavaScript's functional programming helper library.\r\ndeployer/recipes                      6.0.2              3rd party deployer recipes\r\ndoctrine/instantiator                 1.1.0              A small, lightweight utility to instantiate objects in PHP without invoking their constructors\r\ndoctrine/lexer                        v1.0.1             Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.\r\negulias/email-validator               2.1.3              A library for validating emails against several RFCs\r\nextead/yii2-autonumeric               dev-master 9f28033 Input format extension for Yii 2.0 based on autoNumerical plugin\r\nezyang/htmlpurifier                   v4.10.0            Standards compliant HTML filter written in PHP\r\nguzzlehttp/guzzle                     6.3.2              Guzzle is a PHP HTTP client library\r\nguzzlehttp/promises                   v1.3.1             Guzzle promises library\r\nguzzlehttp/psr7                       1.4.2              PSR-7 message implementation that also provides common utility methods\r\nintervention/image                    2.4.1              Image handling and manipulation library with support for Laravel integration\r\nkartik-v/bootstrap-fileinput          v4.4.7             An enhanced HTML 5 file input for Bootstrap 3.x with features for file preview for many file types, multiple selection, ajax uploads, ...\r\nkartik-v/yii2-date-range              v1.6.9             An advanced Yii 2 date range picker input for based on bootstrap-daterangepicker plugin.\r\nkartik-v/yii2-dialog                  v1.0.3             An asset bundle for bootstrap3-dialog for Yii 2.0 framework.\r\nkartik-v/yii2-dynagrid                v1.4.8             Turbo charge the Yii 2 GridView with personalized columns, page size, and themes.\r\nkartik-v/yii2-field-range             v1.3.2             Easily manage Yii 2 ActiveField ranges (from/to) with Bootstrap 3 addons markup and more\r\nkartik-v/yii2-grid                    v3.1.7             Yii 2 GridView on steroids. Various enhancements and utilities for the Yii 2.0 GridView widget.\r\nkartik-v/yii2-helpers                 v1.3.6             A collection of useful helper functions for Yii Framework 2.0\r\nkartik-v/yii2-krajee-base             v1.8.9             Base library and foundation components for all Yii2 Krajee extensions.\r\nkartik-v/yii2-sortable                v1.2.0             Create sortable lists and grids using HTML5 drag and drop API for Yii 2.0.\r\nkartik-v/yii2-widget-activeform       v1.4.9             Enhanced Yii2 active-form and active-field with full bootstrap styling support (sub repo split from yii2-widgets).\r\nkartik-v/yii2-widget-colorinput       v1.0.3             An enhanced Yii 2 widget encapsulating the HTML 5 color input (sub repo split from yii2-widgets)\r\nkartik-v/yii2-widget-datetimepicker   v1.4.4             Enhanced Yii2 wrapper for the bootstrap datetimepicker plugin (sub repo split from yii2-widgets)\r\nkartik-v/yii2-widget-fileinput        v1.0.6             An enhanced FileInput widget for Bootstrap 3.x with file preview, multiple selection, and more features (sub repo split from yii2-widg...\r\nkartik-v/yii2-widget-select2          v2.1.1             Enhanced Yii2 wrapper for the Select2 jQuery plugin (sub repo split from yii2-widgets).\r\nkriswallsmith/assetic                 v1.4.0             Asset Management for PHP\r\nleandrogehlen/yii2-treegrid           dev-master a98305d Extension for Yii2 Framework to work with jQuery TreeGrid\r\nmatthiasmullie/minify                 1.3.59             CSS & JavaScript minifier, in PHP. Removes whitespace, strips comments, combines files (incl. @import statements and small assets in C...\r\nmatthiasmullie/path-converter         1.1.1              Relative path converter\r\nmyclabs/deep-copy                     1.7.0              Create deep copies (clones) of your objects\r\nnesbot/carbon                         1.25.0             A simple API extension for DateTime.\r\noyejorge/less.php                     v1.7.0.14          PHP port of the Javascript version of LESS http://lesscss.org (Originally maintained by Josh Schmidt)\r\nphar-io/manifest                      1.0.1              Component for reading phar.io manifest information from a PHP Archive (PHAR)\r\nphar-io/version                       1.0.1              Library for handling version information and constraints\r\nphpcollection/phpcollection           0.5.0              General-Purpose Collection Library for PHP\r\nphpdocumentor/reflection-common       1.0.1              Common reflection classes used by phpdocumentor to reflect the code structure\r\nphpdocumentor/reflection-docblock     4.3.0              With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in...\r\nphpdocumentor/type-resolver           0.4.0             \r\nphpoption/phpoption                   1.5.0              Option Type for PHP\r\nphpspec/php-diff                      v1.1.0             A comprehensive library for generating differences between two hashable objects (strings or arrays).\r\nphpspec/prophecy                      1.7.5              Highly opinionated mocking framework for PHP 5.3+\r\nphpunit/php-code-coverage             6.0.3              Library that provides collection, processing, and rendering functionality for PHP code coverage information.\r\nphpunit/php-file-iterator             1.4.5              FilterIterator implementation that filters files based on a list of suffixes.\r\nphpunit/php-text-template             1.2.1              Simple template engine.\r\nphpunit/php-timer                     2.0.0              Utility class for timing\r\nphpunit/php-token-stream              3.0.0              Wrapper around PHP's tokenizer extension.\r\nphpunit/phpunit                       7.1.2              The PHP Unit Testing framework.\r\nphpunit/phpunit-mock-objects          6.1.1              Mock Object library for PHPUnit\r\npsr/http-message                      1.0.1              Common interface for HTTP messages\r\nsebastian/code-unit-reverse-lookup    1.0.1              Looks up which function or method a line of code belongs to\r\nsebastian/comparator                  2.1.3              Provides the functionality to compare PHP values for equality\r\nsebastian/diff                        3.0.0              Diff implementation\r\nsebastian/environment                 3.1.0              Provides functionality to handle HHVM/PHP environments\r\nsebastian/exporter                    3.1.0              Provides the functionality to export PHP variables for visualization\r\nsebastian/global-state                2.0.0              Snapshotting of global state\r\nsebastian/object-enumerator           3.0.3              Traverses array structures and object graphs to enumerate all referenced objects\r\nsebastian/object-reflector            1.1.1              Allows reflection of object attributes, including inherited and non-public ones\r\nsebastian/recursion-context           3.0.0              Provides functionality to recursively process PHP variables\r\nsebastian/resource-operations         1.0.0              Provides a list of PHP built-in functions that operate on resources\r\nsebastian/version                     2.0.1              Library that helps with managing the version number of Git-hosted PHP projects\r\nsentry/sentry                         1.8.4              A PHP client for Sentry (http://getsentry.com)\r\nswiftmailer/swiftmailer               v6.0.2             Swiftmailer, free feature-rich PHP mailer\r\nsymfony/browser-kit                   v4.0.8             Symfony BrowserKit Component\r\nsymfony/console                       v4.0.8             Symfony Console Component\r\nsymfony/css-selector                  v4.0.8             Symfony CssSelector Component\r\nsymfony/dom-crawler                   v4.0.8             Symfony DomCrawler Component\r\nsymfony/event-dispatcher              v4.0.8             Symfony EventDispatcher Component\r\nsymfony/finder                        v4.0.8             Symfony Finder Component\r\nsymfony/polyfill-mbstring             v1.7.0             Symfony polyfill for the Mbstring extension\r\nsymfony/process                       v3.4.8             Symfony Process Component\r\nsymfony/translation                   v4.0.6             Symfony Translation Component\r\nsymfony/yaml                          v4.0.8             Symfony Yaml Component\r\ntheseer/tokenizer                     1.1.0              A small library for converting tokenized PHP source code into XML and potentially other formats\r\nunclead/yii2-multiple-input           2.14.0             Widget for handle multiple inputs for an attribute of Yii2 framework model\r\nvlucas/phpdotenv                      v2.4.0             Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.\r\nwebmozart/assert                      1.3.0              Assertions to validate method input/output with nice error messages.\r\nyiisoft/jquery                        2.1.1              jQuery JavaScript Library\r\nyiisoft/jquery-pjax                   v2.0.5             pushState + ajax = pjax, a forked maintainted by the Yii Framework core developers\r\nyiisoft/yii2                          2.0.15.1           Yii PHP Framework Version 2\r\nyiisoft/yii2-bootstrap                2.0.8              The Twitter Bootstrap extension for the Yii framework\r\nyiisoft/yii2-composer                 2.0.6              The composer plugin for Yii extension installer\r\nyiisoft/yii2-debug                    2.0.13             The debugger extension for the Yii framework\r\nyiisoft/yii2-gii                      2.0.6              The Gii extension for the Yii framework\r\nyiisoft/yii2-queue                    2.0.2              Yii2 Queue Extension which supported DB, Redis, RabbitMQ, Beanstalk and Gearman\r\nyiisoft/yii2-redis                    2.0.8              Redis Cache, Session and ActiveRecord for the Yii framework\r\nyiisoft/yii2-sphinx                   2.0.10             Sphinx full text search engine extension for the Yii framework\r\nyiisoft/yii2-swiftmailer              2.1.0              The SwiftMailer integration for the Yii framework\r\n\r\n* Suite configuration:\r\n\r\n```yml\r\nsuite_namespace: frontend\\tests\\functional\r\nactor: FunctionalTester\r\nmodules:\r\n    enabled:\r\n        - \\frontend\\tests\\Helper\\Functional\r\n        - Filesystem\r\n        - Yii2\r\n        - REST:\r\n            url: /\r\n            depends: Yii2\r\n            part: Json\r\n```\r\n\r\nI found problem.\r\nhttps://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Lib/Connector/Yii2.php#L207\r\n\r\n`$content` for json response format is empty.\r\n\r\n```php\r\nif ($response->format == 'json') {\r\n   $content = json_encode($response->data);\r\n}\r\n```\r\nis working\r\n"},"comment":{"url":"https://api.github.com/repos/Codeception/Codeception/issues/comments/388065933","html_url":"https://github.com/Codeception/Codeception/issues/4942#issuecomment-388065933","issue_url":"https://api.github.com/repos/Codeception/Codeception/issues/4942","id":388065933,"user":{"login":"SamMousa","id":547021,"avatar_url":"https://avatars1.githubusercontent.com/u/547021?v=4","gravatar_id":"","url":"https://api.github.com/users/SamMousa","html_url":"https://github.com/SamMousa","followers_url":"https://api.github.com/users/SamMousa/followers","following_url":"https://api.github.com/users/SamMousa/following{/other_user}","gists_url":"https://api.github.com/users/SamMousa/gists{/gist_id}","starred_url":"https://api.github.com/users/SamMousa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamMousa/subscriptions","organizations_url":"https://api.github.com/users/SamMousa/orgs","repos_url":"https://api.github.com/users/SamMousa/repos","events_url":"https://api.github.com/users/SamMousa/events{/privacy}","received_events_url":"https://api.github.com/users/SamMousa/received_events","type":"User","site_admin":false},"created_at":"2018-05-10T14:13:58Z","updated_at":"2018-05-10T14:13:58Z","author_association":"CONTRIBUTOR","body":"In line 182 the response is sent, which causes Yii to prepare it (formatting data and storing it in content).\r\nIn your debug output it also shows no response headers, but the `JsonResponseFormatter` adds a `Content-Type` header.\r\nThis leads me to believe that there is actually something happening in your application causing it to not send the response.\r\n\r\nIf possible please create a minimal test case PR at https://github.com/Codeception/yii2-tests; that way we can fix your issue and prevent future regression."}}
{"actor":{"display_login":"SamMousa"}}