mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 16:40:05 +01:00
Use assertFileExists and assertFileNotExists (#75)
This commit is contained in:
committed by
Taylor Otwell
parent
b08c76e007
commit
05b870b484
@@ -119,13 +119,13 @@ public function test_linked_php_returns_linked_php_formula_name()
|
||||
$files->shouldReceive('isLink')->once()->with('/usr/local/bin/php')->andReturn(true);
|
||||
$files->shouldReceive('readLink')->once()->with('/usr/local/bin/php')->andReturn('/test/path/php70/test');
|
||||
swap(Filesystem::class, $files);
|
||||
$this->assertEquals('php70', resolve(Brew::class)->linkedPhp());
|
||||
$this->assertSame('php70', resolve(Brew::class)->linkedPhp());
|
||||
|
||||
$files = Mockery::mock(Filesystem::class);
|
||||
$files->shouldReceive('isLink')->once()->with('/usr/local/bin/php')->andReturn(true);
|
||||
$files->shouldReceive('readLink')->once()->with('/usr/local/bin/php')->andReturn('/test/path/php56/test');
|
||||
swap(Filesystem::class, $files);
|
||||
$this->assertEquals('php56', resolve(Brew::class)->linkedPhp());
|
||||
$this->assertSame('php56', resolve(Brew::class)->linkedPhp());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public function test_install_caddy_file_places_stub_in_valet_home_directory()
|
||||
$files = Mockery::mock(Filesystem::class.'[putAsUser]');
|
||||
|
||||
$files->shouldReceive('putAsUser')->andReturnUsing(function ($path, $contents) {
|
||||
$this->assertEquals(VALET_HOME_PATH.'/Caddyfile', $path);
|
||||
$this->assertSame(VALET_HOME_PATH.'/Caddyfile', $path);
|
||||
$this->assertTrue(strpos($contents, 'import '.VALET_HOME_PATH.'/Caddy/*') !== false);
|
||||
});
|
||||
|
||||
@@ -71,7 +71,7 @@ public function test_caddy_daemon_is_placed_in_correct_location()
|
||||
$caddy = resolve(Caddy::class);
|
||||
|
||||
$files->shouldReceive('put')->andReturnUsing(function ($path, $contents) use ($caddy) {
|
||||
$this->assertEquals($caddy->daemonPath, $path);
|
||||
$this->assertSame($caddy->daemonPath, $path);
|
||||
$this->assertTrue(strpos($contents, VALET_HOME_PATH) !== false);
|
||||
});
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ public function test_install_installs_and_places_configuration_files_in_proper_l
|
||||
|
||||
$dnsMasq->install('dev');
|
||||
|
||||
$this->assertEquals('nameserver 127.0.0.1'.PHP_EOL, file_get_contents(__DIR__.'/output/resolver/dev'));
|
||||
$this->assertEquals('address=/.dev/127.0.0.1'.PHP_EOL, file_get_contents(__DIR__.'/output/custom-dnsmasq.conf'));
|
||||
$this->assertEquals('test-contents
|
||||
$this->assertSame('nameserver 127.0.0.1'.PHP_EOL, file_get_contents(__DIR__.'/output/resolver/dev'));
|
||||
$this->assertSame('address=/.dev/127.0.0.1'.PHP_EOL, file_get_contents(__DIR__.'/output/custom-dnsmasq.conf'));
|
||||
$this->assertSame('test-contents
|
||||
|
||||
conf-file='.__DIR__.'/output/custom-dnsmasq.conf
|
||||
', file_get_contents(__DIR__.'/output/dnsmasq.conf'));
|
||||
|
||||
@@ -17,9 +17,9 @@ public function test_remove_broken_links_removes_broken_symlinks()
|
||||
$files = new Filesystem;
|
||||
file_put_contents(__DIR__.'/output/file.out', 'test');
|
||||
symlink(__DIR__.'/output/file.out', __DIR__.'/output/file.link');
|
||||
$this->assertTrue(file_exists(__DIR__.'/output/file.link'));
|
||||
$this->assertFileExists(__DIR__.'/output/file.link');
|
||||
unlink(__DIR__.'/output/file.out');
|
||||
$files->removeBrokenLinksAt(__DIR__.'/output');
|
||||
$this->assertFalse(file_exists(__DIR__.'/output/file.link'));
|
||||
$this->assertFileNotExists(__DIR__.'/output/file.link');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public function test_symlink_creates_symlink_to_given_path()
|
||||
swap(Configuration::class, $config);
|
||||
|
||||
$linkPath = resolve(Site::class)->link('target', 'link');
|
||||
$this->assertEquals(VALET_HOME_PATH.'/Sites/link', $linkPath);
|
||||
$this->assertSame(VALET_HOME_PATH.'/Sites/link', $linkPath);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,11 +47,11 @@ public function test_unlink_removes_existing_symlink()
|
||||
symlink(__DIR__.'/output/file.out', __DIR__.'/output/link');
|
||||
$site = resolve(StubForRemovingLinks::class);
|
||||
$site->unlink('link');
|
||||
$this->assertFalse(file_exists(__DIR__.'/output/link'));
|
||||
$this->assertFileNotExists(__DIR__.'/output/link');
|
||||
|
||||
$site = resolve(StubForRemovingLinks::class);
|
||||
$site->unlink('link');
|
||||
$this->assertFalse(file_exists(__DIR__.'/output/link'));
|
||||
$this->assertFileNotExists(__DIR__.'/output/link');
|
||||
}
|
||||
|
||||
|
||||
@@ -62,14 +62,14 @@ public function test_prune_links_removes_broken_symlinks_in_sites_path()
|
||||
unlink(__DIR__.'/output/file.out');
|
||||
$site = resolve(StubForRemovingLinks::class);
|
||||
$site->pruneLinks();
|
||||
$this->assertFalse(file_exists(__DIR__.'/output/link'));
|
||||
$this->assertFileNotExists(__DIR__.'/output/link');
|
||||
}
|
||||
|
||||
|
||||
public function test_logs_method_returns_array_of_log_files()
|
||||
{
|
||||
$logs = resolve(Site::class)->logs([__DIR__.'/test-directory-for-logs']);
|
||||
$this->assertEquals(__DIR__.'/test-directory-for-logs/project/storage/logs/laravel.log', $logs[0]);
|
||||
$this->assertSame(__DIR__.'/test-directory-for-logs/project/storage/logs/laravel.log', $logs[0]);
|
||||
unlink(__DIR__.'/test-directory-for-logs/project/storage/logs/laravel.log');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user