public function testWritePackageFileWritesDefaultParameterValuesOfBindings()
 {
     $packageFile = new PackageFile();
     $package = new Package($packageFile, '/path', new InstallInfo('vendor/package', '/path'));
     // We need to create a type and a binding in state ENABLED
     $bindingType = new BindingTypeDescriptor('my/type', null, array(new BindingParameterDescriptor('param', BindingParameterDescriptor::OPTIONAL, 'default')));
     $bindingType->load($package);
     $binding = new BindingDescriptor('/app/config*.yml', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID1));
     $binding->load($package, $bindingType);
     // The default value is accessible
     $this->assertSame('default', $binding->getParameterValue('param'));
     // But not written by the writer
     $packageFile->addBindingDescriptor($binding);
     $this->writer->writePackageFile($packageFile, $this->tempFile);
     $this->assertFileExists($this->tempFile);
     $this->assertJsonFileEquals(__DIR__ . '/Fixtures/json/binding-no-default-params.json', $this->tempFile);
 }
 private function bindingToMapping(BindingDescriptor $binding)
 {
     return new AssetMapping(substr($binding->getQuery(), 0, -8), $binding->getParameterValue(DiscoveryUrlGenerator::SERVER_PARAMETER), $binding->getParameterValue(DiscoveryUrlGenerator::PATH_PARAMETER), $binding->getUuid());
 }
 /**
  * @expectedException \Puli\Discovery\Api\Binding\NoSuchParameterException
  */
 public function testGetParameterValueWhenLoadedThrowsExceptionIfNotFound()
 {
     $type = new BindingTypeDescriptor('vendor/type');
     $type->load($this->package);
     $descriptor = new BindingDescriptor('/path', 'vendor/type');
     $descriptor->load($this->package, $type);
     $descriptor->getParameterValue('foo');
 }
Пример #4
0
    public function testSerializePackageFileWritesDefaultParameterValuesOfBindings()
    {
        $packageFile = new PackageFile();
        $package = new Package($packageFile, '/path', new InstallInfo('vendor/package', '/path'));
        // We need to create a type and a binding in state ENABLED
        $bindingType = new BindingTypeDescriptor('my/type', null, array(new BindingParameterDescriptor('param', BindingParameterDescriptor::OPTIONAL, 'default')));
        $bindingType->load($package);
        $binding = new BindingDescriptor('/app/config*.yml', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID1));
        $binding->load($package, $bindingType);
        // The default value is accessible
        $this->assertSame('default', $binding->getParameterValue('param'));
        // But not written by the serializer
        $packageFile->addBindingDescriptor($binding);
        $json = <<<JSON
{
    "version": "1.0",
    "bindings": {
        "2438256b-c2f5-4a06-a18f-f79755e027dd": {
            "query": "/app/config*.yml",
            "type": "my/type"
        }
    }
}

JSON;
        $this->assertJsonEquals($json, $this->serializer->serializePackageFile($packageFile));
    }
Пример #5
0
 private function bindingToMapping(BindingDescriptor $binding)
 {
     return new AssetMapping(substr($binding->getQuery(), 0, -8), $binding->getParameterValue(AssetPlugin::TARGET_PARAMETER), $binding->getParameterValue(AssetPlugin::PATH_PARAMETER), $binding->getUuid());
 }