public function testDisableBindingRestoresEnabledBindingsIfSavingFails() { $this->initDefaultManager(); $this->packageFile1->addTypeDescriptor(new BindingTypeDescriptor('my/type', null, array(new BindingParameterDescriptor('param')))); $this->packageFile1->addBindingDescriptor($binding = new BindingDescriptor('/path', 'my/type', array('param' => 'value'), 'xpath')); $this->installInfo1->addEnabledBindingUuid($binding->getUuid()); $this->discovery->expects($this->once())->method('unbind')->with('/path', 'my/type', array('param' => 'value'), 'xpath'); $this->discovery->expects($this->once())->method('bind')->with('/path', 'my/type', array('param' => 'value'), 'xpath'); $this->packageFileStorage->expects($this->once())->method('saveRootPackageFile')->with($this->rootPackageFile)->willThrowException(new TestException('Some exception')); try { $this->manager->disableBinding($binding->getUuid()); $this->fail('Expected an exception'); } catch (TestException $e) { } $this->assertSame(array(), $this->installInfo1->getDisabledBindingUuids()); $this->assertSame(array($binding->getUuid()), $this->installInfo1->getEnabledBindingUuids()); }
public function testAddDisabledBindingUuidRemovesEnabledMapping() { $installInfo = new InstallInfo('vendor/package', '/path'); $uuid = Uuid::uuid4(); $installInfo->addEnabledBindingUuid($uuid); $installInfo->addDisabledBindingUuid($uuid); $this->assertSame(array(), $installInfo->getEnabledBindingUuids()); $this->assertSame(array($uuid), $installInfo->getDisabledBindingUuids()); }