{"id":3151,"date":"2022-08-02T10:36:38","date_gmt":"2022-08-02T01:36:38","guid":{"rendered":"https:\/\/qol-kk.com\/wp2\/?p=3151"},"modified":"2022-08-02T10:36:38","modified_gmt":"2022-08-02T01:36:38","slug":"post-3151","status":"publish","type":"post","link":"https:\/\/qol-kk.com\/wp2\/blog\/2022\/08\/02\/post-3151\/","title":{"rendered":"array_merge(): Argument #1 must be of type array, null given phpunit\u30a8\u30e9\u30fc\u3067\u52d5\u3051\u306a\u3044"},"content":{"rendered":"<h2>array_merge(): Argument #1 must be of type array, null given<\/h2>\n<p>\u30c6\u30b9\u30c8\u66f8\u3044\u3066\u3053\u3093\u306a\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u304d\u307e\u3057\u305f\u3002<br \/>\n\u5358\u7d14\u306a\u30df\u30b9\u304c\u539f\u56e0\u306a\u3093\u3067\u3059\u3051\u3069\u6c17\u3065\u304b\u306a\u3044\u6642\u306f\u6c17\u3065\u304b\u306a\u3044...\u3002<\/p>\n<h3>\u7ffb\u8a33\u6a5f\u306b\u304b\u3051\u308b\u3068\u3053\u3093\u306a\u610f\u5473<\/h3>\n<div class=\"paperBox\">\n<p>array_merge() \u5f15\u6570 #1 \u306f\u914d\u5217\u578b\u3067\u306a\u3051\u308c\u3070\u306a\u3089\u305a\u3001NULL \u304c\u6307\u5b9a\u3055\u308c\u308b<\/p>\n<\/div>\n<p>\u3044\u3084\u3044\u3084\u3001\u305d\u3082\u305d\u3082array_marge\u4f7f\u3063\u3066\u306a\u3044\u3057\u3002<br \/>\n\u3060\u304b\u3089\u914d\u5217\u5408\u6210\u3059\u308b\u306e\u306bNULL\u5165\u3063\u3066\u308b\u3088\u3068\u8a00\u308f\u308c\u3066\u3082\u610f\u5473\u4e0d\u660e\u3060\u3057\u3002<\/p>\n<p>\u306f\u3044\u3001\u305d\u308c\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u304c\u539f\u56e0\u3060\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h3>\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u306b\u3010__constract\u3011\u306f\u4f7f\u3048\u306a\u3044<\/h3>\n<p>__constract\u306b\u8a18\u8f09\u3057\u3066\u3044\u305f\u3082\u306e\u3092SetUp\u306b\u8a18\u8f09\u3059\u308b\u3060\u3051\u3067\u30a8\u30e9\u30fc\u89e3\u6d88\u3067\u3059\u3002<br \/>\n\u771f\u9762\u76ee\u306b\u3053\u308c\u3060\u3051\u306e\u8a71\u306a\u306e\u3067\u3059\u304c\u3001\u3061\u3087\u3063\u3068\u77ed\u3059\u304e\u308b\u306e\u3067\u5c11\u3005\u89e3\u8aac\u3092\u3002<\/p>\n<h3>__constract\u3092\u4f7f\u3044\u305f\u3044\u7406\u7531<\/h3>\n<p>constract\u81ea\u4f53\u306b\u3064\u3044\u3066\u306f\u4e0b\u306e\u8a18\u4e8b\u3067\u3054\u78ba\u8a8d\u304f\u3060\u3055\u3044\u3002<br \/>\n<a href=\"https:\/\/qol-kk.com\/wp2\/blog\/2021\/11\/17\/post-3107\/\">laravel\u306e\u300c__construct()\u3063\u3066\u306a\u3093\u3060\u300d\u306b\u3064\u3044\u3066<\/a><\/p>\n<p>\u591a\u5206\u3082\u3063\u3068\u3082\u5927\u3044\u7406\u7531\u304cFunction\u304cstatic\u3067\u306f\u306a\u3044\u304b\u3089\u3060\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\ncontroller\u3084service\u3067static\u3067\u306f\u306a\u3044function\u3092\u547c\u3076\u969b\u306b\u306fnew\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u3053\u306enew\u3092\u884c\u3046\u5834\u6240\u3068\u3057\u3066\u5229\u7528\u3055\u308c\u308b\u306e\u304cconstract\u3067\u3059\u3002<br \/>\n\u306a\u306e\u3067\u3001\u305d\u306e\u6d41\u308c\u3067TEST\u306b\u3082\u66f8\u3044\u3066\u3057\u307e\u3063\u305f\u308a\u3057\u307e\u3059\u304c\u3001\u3053\u308c\u304c\u30a8\u30e9\u30fc\u306e\u539f\u56e0\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>Test\u3067\u306fSetUp\u304c\u6bce\u56de\u8aad\u307f\u8fbc\u307e\u308c\u308b<\/h3>\n<p>\u3069\u306efunction\u304c\u3069\u3046\u8aad\u307f\u8fbc\u307e\u308c\u308b\u304b\u3092\u8003\u3048\u308b\u3068\u3001Test\u3067\u306fSetUp\u304c\u6bce\u56de\u8aad\u307e\u308c\u307e\u3059\u3088\u306d\u3002<br \/>\nSetUp\u3067\u306f\u4e3b\u306bTestDB\u306b\u5024\u3092\u683c\u7d0d\u3059\u308b\u5de5\u7a0b\u3067\u5229\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u3067\u3001Service\u3084Controller\u306enew\u3082\u3053\u3053\u3067\u8d70\u3089\u305b\u308b\u306e\u3067\u3059\u304c\u3010\u304a\u4f5c\u6cd5\u3011\u3068\u3057\u3066\u8a18\u8f09\u65b9\u6cd5\u304c\u5c11\u3057\u5909\u308f\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">&lt;?php\r\n\r\nnamespace Tests\\Unit\\Services;\r\n\r\nuse Tests\\TestCase;\r\nuse App\\Services\\HogeService;\r\nuse Illuminate\\Foundation\\Testing\\WithFaker;\r\nuse Illuminate\\Foundation\\Testing\\RefreshDatabase;\r\n\r\nclass HogeServiceTest extends TestCase\r\n{\r\n    use RefreshDatabase;\r\n    use WithFaker;\r\n\r\n\u3000\u3000\u3000\u3000protected $service;\r\n\r\n    protected function setUp(): void\r\n    {\r\n        parent::setUp();\r\n        $this-&gt;artisan('config:clear');\r\n\r\n        # \u3053\u306e\u3088\u3046\u306b\u66f8\u304f\r\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000    $this-&gt;service = app()-&gt;make(HogeService::class);\r\n    }\r\n\r\n    public function test_get_\u4efb\u610f\u306e\u5024\u3067Data\u53ce\u96c6()\r\n    {\r\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000$this-&gt;service-&gt;Function\u540d\uff08\uff09;\r\n    }\r\n}<\/pre>\n<div class=\"borderBox\">$this-&gt;service = app()-&gt;make(HogeService::class);<\/div>\n<p>$this-&gt;service = new HogeService;\u3067\u306f\u306a\u3044\u3093\u3067\u3059\u306d\u3002<br \/>\n\u3053\u306e\u8a18\u8f09\u65b9\u6cd5\u306f\u79c1\u3082\u4eca\u306e\u73fe\u5834\u3067\u521d\u3081\u3066\u77e5\u308a\u307e\u3057\u305f\u3002<br \/>\n\u3061\u306a\u307f\u306b\u3001<strong>$this-&gt;service = new HogeService;<\/strong>\u3067\u3082\u554f\u984c\u306a\u304f\u52d5\u304d\u307e\u3059\u3002<\/p>\n<h3>\u307e\u3068\u3081<\/h3>\n<p>\u898b\u305f\u3053\u3068\u306e\u306a\u3044\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u304f\u308b\u3068\u30d5\u30ea\u30fc\u30ba\u3057\u307e\u3059\u3088\u306d\u3002<br \/>\n\u4eca\u56de\u306f\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u306e\u304a\u8a71\u3067\u3059\u304c\u3001\u4eca\u6d41\u884c\u308a\u306e\u30a2\u30b8\u30e3\u30a4\u30eb\u958b\u767a\u3060\u30681\u3064\u306e\u6a5f\u80fd\u306e\u5b9f\u88c5\u3092\u30c6\u30b9\u30c8\u307e\u3067\u8cc4\u3044\u307e\u3059\u3002<br \/>\n\u305d\u306e\u305f\u3081\u3001\u9762\u8ac7\u306e\u969b\u306b\u30c6\u30b9\u30c8\u3092\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u308b\u304b\u3068\u3044\u3046\u8cea\u554f\u3092\u53d7\u3051\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u81ea\u4f5c\u30b7\u30b9\u30c6\u30e0\u3067\u306f\u30c6\u30b9\u30c8\u3092\u66f8\u304f\u3053\u3068\u3088\u308a\u3082\u6a5f\u80fd\u3092\u30ac\u30f3\u30ac\u30f3\u7a4d\u307f\u4e0a\u3052\u308b\u3053\u3068\u3092\u512a\u5148\u3057\u3066\u3044\u305f\u306e\u3067\u5c11\u3005\u82e6\u624b\u3067\u3059\u3002<br \/>\n\uff08\u30c6\u30b9\u30c8\u3063\u3066DB\u304b\u3089\u5024\u6d88\u3048\u3061\u3083\u3046\u306e\u3067\u3001\u751f\u30c7\u30fc\u30bf\u3092\u5229\u7528\u3057\u3066\u958b\u767a\u3057\u3066\u3044\u305f\u79c1\u3068\u3057\u3066\u306f\u624b\u3092\u51fa\u305b\u306a\u304b\u3063\u305f\u306e\u3067\u3059\uff09<br \/>\n\u3067\u3082\u3001\u7d76\u5bfe\u306b\u3084\u3063\u305f\u307b\u3046\u304c\u826f\u3044\u3053\u3068\u3067\u306f\u3042\u308b\u3057\u3001\u5c11\u306a\u3044\u30b3\u30fc\u30c9\u3067\u4f5c\u696d\u3059\u308c\u3070Seed\u3067\u6642\u9593\u53d6\u3089\u306a\u3044\u3057\u3001\u307e\u3041\u305d\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>array_merge(): Argument #1 must be of type array, null given \u30c6\u30b9\u30c8\u66f8\u3044\u3066\u3053\u3093\u306a\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u304d\u307e\u3057\u305f\u3002 \u5358\u7d14\u306a\u30df\u30b9\u304c\u539f\u56e0\u306a\u3093\u3067\u3059\u3051\u3069\u6c17\u3065\u304b\u306a\u3044\u6642\u306f\u6c17\u3065\u304b\u306a\u3044.. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":944,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[34,75],"tags":[1132,153,98,97,53,1147],"class_list":["post-3151","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php-memorandum","category-code-of-serverside","tag-__constract","tag-laravel","tag-php","tag-97","tag-53","tag-1147"],"veu_head_title_object":{"title":"","add_site_title":""},"jetpack_publicize_connections":[],"jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/qol-kk.com\/wp2\/wp-content\/uploads\/2018\/11\/laravel_logo.png","_links":{"self":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/3151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/comments?post=3151"}],"version-history":[{"count":0,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/3151\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media\/944"}],"wp:attachment":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media?parent=3151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/categories?post=3151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/tags?post=3151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}