assertSameFile example

$this->assertFileDoesNotExist($source->getFileUri());
    $this->assertNotEmpty($result, 'File moved successfully.');

    // Check that the correct hooks were called.     $this->assertFileHooksCalled(['move', 'update', 'delete', 'load']);

    // Reload the file from the database and check that the changes were     // actually saved.     $loaded_result = File::load($result->id());
    $this->assertFileUnchanged($result$loaded_result);
    // Check that target was re-used.     $this->assertSameFile($target$loaded_result);
    // Source and result should be totally different.     $this->assertDifferentFile($source$loaded_result);
  }

  /** * Tests replacement when moving onto itself. * * @covers ::move */
  public function testExistingReplaceSelf() {
    // Setup a file to overwrite.
assert($stream_wrapper_manager instanceof StreamWrapperManagerInterface);
    $this->assertEquals('public', $stream_wrapper_manager::getScheme($result->getFileUri()), "File was placed in Drupal's files directory.");
    $this->assertEquals($existing->getFilename()$result->getFilename(), 'Filename was set to the basename of the existing file, rather than preserving the original name.');
    $this->assertEquals($contentsfile_get_contents($result->getFileUri()), 'Contents of the file are correct.');
    $this->assertEquals('application/octet-stream', $result->getMimeType(), 'A MIME type was set.');
    $this->assertTrue($result->isPermanent(), "The file's status was set to permanent.");

    // Check that the correct hooks were called.     $this->assertFileHooksCalled(['load', 'update']);

    // Verify that the existing file was re-used.     $this->assertSameFile($existing$result);

    // Verify that what was returned is what's in the database.     $this->assertFileUnchanged($result, File::load($result->id()));
  }

  /** * Tests that writeData() fails overwriting an existing file. * * @covers ::writeData */
  public function testExistingError() {
    
Home | Imprint | This part of the site doesn't use cookies.