public function testIsUnique() { $file = factory(File::class)->create(); $md5 = md5('asdfasdfsdasdf'); $this->assertTrue(File::isUnique($md5)); $this->assertFalse(File::isUnique($file->md5)); }
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); }
public function destroy(File $files) { $files->delete(); return response()->json('', Response::HTTP_NO_CONTENT); }