The
mix
function returns the path to a versioned Mix file:<?php $path = mix('css/app.css');
<?php $manifest = $this->makeManifest();
$result = mix('/unversioned.css');
$this->assertSame('/versioned.css', $result->toHtml());
<?php $app['config']->shouldReceive('get')->with('app.mix_hot_proxy_url');
$manifest = $this->makeManifest();
mix('unversioned.css');
unlink($manifest);
$result = mix('/unversioned.css');
<?php mix('unversioned.css');
unlink($manifest);
$result = mix('/unversioned.css');
$this->assertSame('/versioned.css', $result->toHtml());
}
<?php $manifest = $this->makeManifest();
$result = mix('unversioned.css');
$this->assertSame('/versioned.css', $result->toHtml());
<?php $this->expectException(Exception::class);
$this->expectExceptionMessage('Mix manifest not found');
mix('unversioned.css', 'missing');
}
public function testMixWithManifestDirectory()
<?php mkdir($directory = __DIR__.'/mix');
$manifest = $this->makeManifest('mix');
$result = mix('unversioned.css', 'mix');
$this->assertSame('/mix/versioned.css', $result->toHtml());
<?php mkdir($directory = __DIR__.'/mix');
$manifest = $this->makeManifest('/mix');
$result = mix('unversioned.css', 'mix');
$this->assertSame('/mix/versioned.css', $result->toHtml());
<?php {
$path = $this->makeHotModuleReloadFile('https://laravel.com/docs');
$result = mix('unversioned.css');
$this->assertSame('//laravel.com/docs/unversioned.css', $result->toHtml());
<?php {
$path = $this->makeHotModuleReloadFile('http://laravel.com/docs');
$result = mix('unversioned.css');
$this->assertSame('//laravel.com/docs/unversioned.css', $result->toHtml());
<?php mkdir($directory = __DIR__.'/mix');
$path = $this->makeHotModuleReloadFile('https://laravel.com/docs', 'mix');
$result = mix('unversioned.css', 'mix');
$this->assertSame('//laravel.com/docs/unversioned.css', $result->toHtml());
<?php mkdir($directory = __DIR__.'/mix');
$path = $this->makeHotModuleReloadFile('http://laravel.com/docs', 'mix');
$result = mix('unversioned.css', 'mix');
$this->assertSame('//laravel.com/docs/unversioned.css', $result->toHtml());
<?php {
$path = $this->makeHotModuleReloadFile('');
$result = mix('unversioned.css');
$this->assertSame('//localhost:8080/unversioned.css', $result->toHtml());
<?php mkdir($directory = __DIR__.'/mix');
$path = $this->makeHotModuleReloadFile('', 'mix');
$result = mix('unversioned.css', 'mix');
$this->assertSame('//localhost:8080/unversioned.css', $result->toHtml());
<?php return 'expected';
});
$this->assertSame('expected', mix('asset.png'));
}
}
<?php {
$instance = $this->withoutMix();
$this->assertSame('', (string) mix('path/to/asset.png'));
$this->assertSame($this, $instance);
}