You are here

public function vfsStreamWrapperFileTimesTestCase::writeFileChangesModificationTime in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperFileTimesTestCase.php \org\bovigo\vfs\vfsStreamWrapperFileTimesTestCase::writeFileChangesModificationTime()

@test @group issue_7

File

vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperFileTimesTestCase.php, line 155

Class

vfsStreamWrapperFileTimesTestCase
Test for org\bovigo\vfs\vfsStreamWrapper.

Namespace

org\bovigo\vfs

Code

public function writeFileChangesModificationTime() {
  $file = vfsStream::newFile('foo.txt')
    ->at(vfsStreamWrapper::getRoot())
    ->lastModified(100)
    ->lastAccessed(100)
    ->lastAttributeModified(100);
  $fp = fopen($this->fooUrl, 'wb');
  $openTime = time();
  sleep(2);
  fwrite($fp, 'test');
  fclose($fp);
  $this
    ->assertLessThanOrEqual($openTime + 3, filemtime($this->fooUrl));
  $this
    ->assertLessThanOrEqual($openTime, fileatime($this->fooUrl));
  $this
    ->assertEquals(100, filectime($this->fooUrl));
  $this
    ->assertFileTimesEqualStreamTimes($this->fooUrl, $file);
}