Пример #1
0
 public function testIsUnique()
 {
     $file = factory(File::class)->create();
     $md5 = md5('asdfasdfsdasdf');
     $this->assertTrue(File::isUnique($md5));
     $this->assertFalse(File::isUnique($file->md5));
 }
Пример #2
0
 public function testPatchFiles()
 {
     // create user info and convert it to json
     $fileObject = factory(File::class)->create();
     $fileObject->name = 'filetastic';
     $fileData = json_encode(['data' => ['type' => 'files', 'attributes' => $fileObject->toArray()]]);
     $response = $this->callPatch(self::API_URL . $fileObject->id, $fileData);
     $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
     $this->assertNotNull($file = json_decode($response->getContent())->data);
     $this->assertNotEmpty($file->id);
     // test to make sure the user was created
     $updatedFile = File::findOrFail($file->id);
     $this->assertEquals('filetastic', $updatedFile->name);
 }
Пример #3
0
 public function destroy(File $files)
 {
     $files->delete();
     return response()->json('', Response::HTTP_NO_CONTENT);
 }