Merge branch '3.5' into 3

This commit is contained in:
Daniel Hensby 2017-01-16 21:00:14 +00:00
commit 2ce80e448d
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
2 changed files with 78 additions and 1 deletions

View File

@ -99,7 +99,7 @@ class SS_ConfigManifest {
}
// If we don't have a variantKeySpec (because we're forcing regen, or it just wasn't in the cache), generate it
if (false === $this->variantKeySpec) {
if (false === $this->phpConfigSources || false === $this->variantKeySpec) {
$this->regenerate($includeTests);
}

View File

@ -152,6 +152,83 @@ class ConfigManifestTest extends SapphireTest {
$manifest->__construct(dirname(__FILE__).'/fixtures/configmanifest', false, false);
}
/**
* Test cache regeneration if all or some of the cache files are missing
*
* 1. Test regeneration if all cache files are missing
* 2. Test regeneration if 'variant_key_spec' cache file is missing
* 3. Test regeneration if 'php_config_sources' cache file is missing
*/
public function testAutomaticCacheRegeneration(){
$base = dirname(__FILE__) . '/fixtures/configmanifest';
// Test regeneration if all cache files are missing
$manifest = $this->getManifestMock(array('getCache', 'regenerate', 'buildYamlConfigVariant'));
$manifest->expects($this->once())// regenerate should be called once
->method('regenerate')
->with($this->equalTo(false)); // includeTests = false
// Set up a cache where we expect load to never be called
$cache = $this->getCacheMock();
$cache->expects($this->exactly(2))
->will($this->returnValue(false))
->method('load');
$manifest->expects($this->any())
->method('getCache')
->will($this->returnValue($cache));
$manifest->__construct($base);
// Test regeneration if 'variant_key_spec' cache file is missing
$manifest = $this->getManifestMock(array('getCache', 'regenerate', 'buildYamlConfigVariant'));
$manifest->expects($this->once())// regenerate should be called once
->method('regenerate')
->with($this->equalTo(false)); // includeTests = false
$cache = $this->getCacheMock();
$cache->expects($this->exactly(2))
->method('load')
->will($this->returnCallback(function ($parameter) {
if (strpos($parameter, 'variant_key_spec') !== false) {
return false;
}
return array();
}));
$manifest->expects($this->any())
->method('getCache')
->will($this->returnValue($cache));
$manifest->__construct($base);
// Test regeneration if 'php_config_sources' cache file is missing
$manifest = $this->getManifestMock(array('getCache', 'regenerate', 'buildYamlConfigVariant'));
$manifest->expects($this->once())// regenerate should be called once
->method('regenerate')
->with($this->equalTo(false)); // includeTests = false
$cache = $this->getCacheMock();
$cache->expects($this->exactly(2))
->method('load')
->will($this->returnCallback(function ($parameter) {
if (strpos($parameter, 'php_config_sources') !== false) {
return false;
}
return array();
}));
$manifest->expects($this->any())
->method('getCache')
->will($this->returnValue($cache));
$manifest->__construct($base);
}
/**
* This test checks the processing of before and after reference paths (module-name/filename#fragment)
* This method uses fixture/configmanifest/mysite/_config/addyamlconfigfile.yml as a fixture