private function getUniqueIds($formIds, $propertyIds) { $ids = []; $unique = false; while (!$unique) { $formId = $this->faker->randomElement($formIds); $propertyId = $this->faker->randomElement($propertyIds); $form = Form::find($formId); $property = $form->properties->filter(function ($property) use($propertyId) { return $property->id === $propertyId; }); if ($property->isEmpty()) { $unique = true; $ids = ['form_id' => $formId, 'property_id' => $propertyId]; } } return $ids; }
/** @test */ public function it_updates_a_form() { $data = ['slug' => 'test-form-77', 'relations' => ['sync' => ['properties' => [4 => ['label' => 'abcd', 'default' => '1', 'required' => 0], 5 => ['label' => 'efgh', 'default' => '2', 'required' => 0], 6 => ['label' => 'ijkl', 'default' => '3', 'required' => 0]]], 'attach' => ['tags' => [10]]]]; $response = $this->call('PUT', 'api/forms/1', [], [], [], $this->headers, json_encode($data)); $content = json_decode($response->getContent()); $updatedForm = \SevenShores\Kraken\Form::find(1); $this->assertEquals(200, $response->getStatusCode()); $this->assertEquals($data['slug'], $content->slug); $this->assertEquals($data['slug'], $updatedForm->slug); $this->assertEquals(3, $updatedForm->properties->count()); $this->assertEquals(10, $updatedForm->tags->last()->id); }