コード例 #1
0
ファイル: ChildEntityTest.php プロジェクト: spira/api-core
 public function testDeleteManyInvalidId()
 {
     $entity = factory(TestEntity::class)->create();
     $this->addRelatedEntities($entity);
     $childCount = TestEntity::find($entity->entity_id)->testMany->count();
     $childEntities = $entity->testMany;
     $childEntities->first()->entity_id = (string) Uuid::uuid4();
     $childEntities->last()->entity_id = (string) Uuid::uuid4();
     $data = array_map(function ($entity) {
         return ['entityId' => $entity->entity_id, 'value' => 'foobar'];
     }, $childEntities->all());
     $this->withAuthorization()->deleteJson('/test/entities/' . $entity->entity_id . '/children', $data);
     $object = json_decode($this->response->getContent());
     $this->assertTrue(is_array($object->invalid));
     $this->assertObjectHasAttribute('entityId', $object->invalid[0]);
     $this->assertNull($object->invalid[1]);
     $this->assertObjectHasAttribute('entityId', $object->invalid[4]);
     $this->assertEquals('The selected entity id is invalid.', $object->invalid[0]->entityId[0]->message);
     $this->assertEquals($childCount, TestEntity::find($entity->entity_id)->testMany->count());
 }
コード例 #2
0
ファイル: EntityTest.php プロジェクト: spira/api-core
 public function testPatchMany()
 {
     $entities = factory(TestEntity::class, 5)->create();
     $this->expectElasticSearchReindexMany(5);
     $data = array_map(function ($entity) {
         return ['entity_id' => $entity->entity_id, 'varchar' => 'foobar'];
     }, $entities->all());
     $this->withAuthorization()->patchJson('/test/entities', $data);
     $entity = TestEntity::find($entities->random()->entity_id);
     $this->assertResponseStatus(204);
     $this->assertResponseHasNoContent();
     $this->assertEquals('foobar', $entity->varchar);
 }