public function testExcept() { $data = new Collection(['first' => 'Taylor', 'last' => 'Otwell', 'email' => '*****@*****.**']); $this->assertEquals(['first' => 'Taylor'], $data->except(['last', 'email', 'missing'])->all()); $this->assertEquals(['first' => 'Taylor'], $data->except('last', 'email', 'missing')->all()); $this->assertEquals(['first' => 'Taylor', 'email' => '*****@*****.**'], $data->except(['last'])->all()); $this->assertEquals(['first' => 'Taylor', 'email' => '*****@*****.**'], $data->except('last')->all()); }
/** * @test */ public function exceptが指定した配列の要素を除外した配列を返す() { $collection = new Collection(['product_id' => 1, 'name' => 'Desk', 'price' => 100, 'discount' => false]); $filtered = $collection->except(['price', 'discount']); $this->assertEquals(['product_id' => 1, 'name' => 'Desk'], $filtered->all()); }