Bart\Configuration\TestConfig::configureForTesting PHP Method

configureForTesting() public method

public configureForTesting ( array $configsArray )
$configsArray array The new internal configurations
    public function configureForTesting(array $configsArray)
    {
        $this->configurations = $configsArray;
        // Some rigmarole for any methods using updateRuntimeConfiguration
        $pathField = Reflection_Helper::get_property('Bart\\Configuration\\Configuration', 'filePath');
        $pathField->setValue($this, '');
        TestConfigurationsHelper::setConfigCache($configsArray);
    }

Usage Example

Beispiel #1
0
 public function testGetSecret()
 {
     $this->shmockAndDieselify('\\Bart\\Shell', function ($shell) {
         $shell->std_in_secret()->once()->return_value('078-05-1120');
     });
     $configs = new TestConfig();
     $configs->configureForTesting([]);
     $social = $configs->getSocialSecurityNumber();
     $this->assertEquals('078-05-1120', $social, 'social');
     // Should use cache and not call std_in_secret a second time
     $social = $configs->getSocialSecurityNumber();
     $this->assertEquals('078-05-1120', $social, 'social');
 }