{"action":"created","issue":{"url":"https://api.github.com/repos/laruence/yaf/issues/213","labels_url":"https://api.github.com/repos/laruence/yaf/issues/213/labels{/name}","comments_url":"https://api.github.com/repos/laruence/yaf/issues/213/comments","events_url":"https://api.github.com/repos/laruence/yaf/issues/213/events","html_url":"https://github.com/laruence/yaf/issues/213","id":118265407,"number":213,"title":"Phpunit测试Yaf Action, __construct时出现core","user":{"login":"lancerhe","id":3190175,"avatar_url":"https://avatars.githubusercontent.com/u/3190175?v=3","gravatar_id":"","url":"https://api.github.com/users/lancerhe","html_url":"https://github.com/lancerhe","followers_url":"https://api.github.com/users/lancerhe/followers","following_url":"https://api.github.com/users/lancerhe/following{/other_user}","gists_url":"https://api.github.com/users/lancerhe/gists{/gist_id}","starred_url":"https://api.github.com/users/lancerhe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lancerhe/subscriptions","organizations_url":"https://api.github.com/users/lancerhe/orgs","repos_url":"https://api.github.com/users/lancerhe/repos","events_url":"https://api.github.com/users/lancerhe/events{/privacy}","received_events_url":"https://api.github.com/users/lancerhe/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-11-22T14:11:34Z","updated_at":"2015-11-23T15:25:30Z","closed_at":"2015-11-23T15:25:30Z","body":"做Unit Test 尝试Mock Request, Response, View后，初始化Action出现core\r\n```\r\n    /**\r\n     * @test\r\n     */\r\n    public function category_has_exists() {\r\n        $stubRequest  = $this->getMockBuilder('\\Yaf\\Request\\Http')\r\n                        ->setConstructorArgs(['/article/addcategory/name/News2'])\r\n                        ->getMock();\r\n        \\Yaf\\Dispatcher::getInstance()->getRouter()->route($stubRequest);\r\n        $stubResponse = $this->getMockBuilder('\\Yaf\\Response\\Http')\r\n                        ->disableOriginalConstructor()\r\n                        ->getMock();\r\n        $stubView     = $this->getMockBuilder('\\Yaf\\View\\Simple')\r\n                        ->disableOriginalConstructor()\r\n                        ->getMock();\r\n        // print_r($stubRequest);print_r($stubResponse);print_r($stubView);exit();\r\n        $Action = new Action_AddCategory($stubRequest, $stubResponse, $stubView);\r\n    }\r\n```\r\n这三个对象打印出来的结果是\r\n```\r\nMock_Http_aa4dcf82 Object\r\n(\r\n    [__phpunit_invocationMocker:Mock_Http_aa4dcf82:private] =>\r\n    [__phpunit_originalObject:Mock_Http_aa4dcf82:private] =>\r\n    [module] =>\r\n    [controller] => article\r\n    [action] => addcategory\r\n    [method] => Cli\r\n    [params:protected] => Array\r\n        (\r\n            [name] => News2\r\n        )\r\n\r\n    [language:protected] =>\r\n    [_exception:protected] =>\r\n    [_base_uri:protected] =>\r\n    [uri:protected] => /article/addcategory/name/News2\r\n    [dispatched:protected] =>\r\n    [routed:protected] => 1\r\n)\r\nMock_Http_36c466f4 Object\r\n(\r\n    [__phpunit_invocationMocker:Mock_Http_36c466f4:private] =>\r\n    [__phpunit_originalObject:Mock_Http_36c466f4:private] =>\r\n    [_header:protected] =>\r\n    [_body:protected] =>\r\n    [_sendheader:protected] => 1\r\n    [_response_code:protected] => 200\r\n)\r\nMock_Simple_a459539b Object\r\n(\r\n    [__phpunit_invocationMocker:Mock_Simple_a459539b:private] =>\r\n    [__phpunit_originalObject:Mock_Simple_a459539b:private] =>\r\n    [_tpl_vars:protected] =>\r\n    [_tpl_dir:protected] =>\r\n    [_options:protected] =>\r\n)\r\n```\r\n跑UT的结果就是core，\r\n```\r\n[lancer@Lancer-MacBookPro yaf-phpunit]$ phpunit -c tests/phpunit.xml\r\nPHPUnit 4.7.6 by Sebastian Bergmann and contributors.\r\n\r\nSegmentation fault: 11\r\n```\r\n另外问一个问题，为何我Mac下用gdb调试core发现 `no core file handler recognizes format`\r\n```\r\n[lancer@Lancer-MacBookPro yaf-phpunit]$ gdb -c /cores/core.6327\r\nGNU gdb (GDB) 7.9.1\r\nCopyright (C) 2015 Free Software Foundation, Inc.\r\nLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\r\nThis is free software: you are free to change and redistribute it.\r\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\r\nand \"show warranty\" for details.\r\nThis GDB was configured as \"x86_64-apple-darwin14.3.0\".\r\nType \"show configuration\" for configuration details.\r\nFor bug reporting instructions, please see:\r\n<http://www.gnu.org/software/gdb/bugs/>.\r\nFind the GDB manual and other documentation resources online at:\r\n<http://www.gnu.org/software/gdb/documentation/>.\r\nFor help, type \"help\".\r\nType \"apropos word\" to search for commands related to \"word\".\r\n\"/cores/core.6327\": no core file handler recognizes format\r\n(gdb)\r\n```"},"comment":{"url":"https://api.github.com/repos/laruence/yaf/issues/comments/158967514","html_url":"https://github.com/laruence/yaf/issues/213#issuecomment-158967514","issue_url":"https://api.github.com/repos/laruence/yaf/issues/213","id":158967514,"user":{"login":"lancerhe","id":3190175,"avatar_url":"https://avatars.githubusercontent.com/u/3190175?v=3","gravatar_id":"","url":"https://api.github.com/users/lancerhe","html_url":"https://github.com/lancerhe","followers_url":"https://api.github.com/users/lancerhe/followers","following_url":"https://api.github.com/users/lancerhe/following{/other_user}","gists_url":"https://api.github.com/users/lancerhe/gists{/gist_id}","starred_url":"https://api.github.com/users/lancerhe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lancerhe/subscriptions","organizations_url":"https://api.github.com/users/lancerhe/orgs","repos_url":"https://api.github.com/users/lancerhe/repos","events_url":"https://api.github.com/users/lancerhe/events{/privacy}","received_events_url":"https://api.github.com/users/lancerhe/received_events","type":"User","site_admin":false},"created_at":"2015-11-23T15:25:30Z","updated_at":"2015-11-23T15:25:30Z","body":"@laruence \r\nsorry. 我是make test... 忘了make install.\r\n我刚重新测试了一下，OX S / Centos 只有在master(2.3.6-dev)正常，2.3.5下出现Core。\r\n按之前的说法应该是在最新的master上修复了类似问题，感谢哈！"}}