name = 'test_it_can_update_a_segment_constant_SEG'; $segment->save(); $constant = new SegmentConstant(); $constant->segment_id = $segment->id; $constant->name = 'test_it_can_update_a_segment_constant_OLD'; $constant->reference = 'old-reference'; $constant->detail = (object) ['old' => 'detail']; $constant->save(); $newDetail = ['new' => 'detail']; $object = new ConstantObject('test_it_can_update_a_segment_constant_NEW', 'test_it_can_update_a_segment_constant_REF', $newDetail); $service = new UpdatesConstant(); // A C T $result = $service->execute($constant, $object); // A S S E R T $this->assertInstanceOf(SegmentConstant::class, $result); $this->assertEquals('test_it_can_update_a_segment_constant_NEW', $result->name); $this->assertEquals('test_it_can_update_a_segment_constant_REF', $result->reference); $this->assertEquals((object) $newDetail, $result->detail); $this->assertEquals($constant->id, $result->id); $this->assertDatabaseHas('segment_constants', [ 'id' => $constant->id, 'name' => 'test_it_can_update_a_segment_constant_NEW', 'reference' => 'test_it_can_update_a_segment_constant_REF', ]); } }