|
15 | 15 |
|
16 | 16 | namespace TYPO3\CMS\ComposerTest\Installer; |
17 | 17 |
|
| 18 | +use Composer\Composer; |
18 | 19 | use Composer\Package\Package; |
| 20 | +use TYPO3\CMS\Composer\Plugin\Util\Filesystem as TYPO3Filesystem; |
19 | 21 |
|
20 | 22 | class ExtensionInstallerTest extends InstallerTestCase |
21 | 23 | { |
@@ -96,4 +98,64 @@ public function extensionInstallPathDataProvider() |
96 | 98 | ], |
97 | 99 | ]; |
98 | 100 | } |
| 101 | + |
| 102 | + public function testUpdate() |
| 103 | + { |
| 104 | + $filesystem = $this->getMockBuilder(TYPO3Filesystem::class) |
| 105 | + ->getMock(); |
| 106 | + $filesystem |
| 107 | + ->expects($this->once()) |
| 108 | + ->method('rename') |
| 109 | + ->with('/typo3conf/ext/old', '/typo3conf/ext/new'); |
| 110 | + |
| 111 | + /** @var Package $package */ |
| 112 | + $initial = $this->createPackage('somevendor/somepackage-extension', 'typo3-cms-extension'); |
| 113 | + $initial->setExtra([ |
| 114 | + 'typo3/cms' => [ |
| 115 | + 'extension-key' => 'old', |
| 116 | + ], |
| 117 | + ]); |
| 118 | + |
| 119 | + /** @var Package $package */ |
| 120 | + $target = $this->createPackage('somevendor/somepackage-extension', 'typo3-cms-extension'); |
| 121 | + $target->setExtra([ |
| 122 | + 'typo3/cms' => [ |
| 123 | + 'extension-key' => 'new', |
| 124 | + ], |
| 125 | + ]); |
| 126 | + |
| 127 | + $this->repository |
| 128 | + ->expects($this->exactly(3)) |
| 129 | + ->method('hasPackage') |
| 130 | + ->will($this->onConsecutiveCalls(true, false, false)); |
| 131 | + |
| 132 | + if (!defined('Composer\Composer::RUNTIME_API_VERSION') || version_compare(Composer::RUNTIME_API_VERSION, '2.0.0') < 0) { |
| 133 | + $this->downloadManager |
| 134 | + ->expects($this->once()) |
| 135 | + ->method('update') |
| 136 | + ->with($initial, $target, '/typo3conf/ext/new'); |
| 137 | + } else { |
| 138 | + $this->downloadManager |
| 139 | + ->expects($this->once()) |
| 140 | + ->method('update') |
| 141 | + ->with($initial, $target, '/typo3conf/ext/new') |
| 142 | + ->will($this->returnValue(\React\Promise\resolve())); |
| 143 | + } |
| 144 | + |
| 145 | + $this->repository |
| 146 | + ->expects($this->once()) |
| 147 | + ->method('removePackage') |
| 148 | + ->with($initial); |
| 149 | + |
| 150 | + $this->repository |
| 151 | + ->expects($this->once()) |
| 152 | + ->method('addPackage') |
| 153 | + ->with($target); |
| 154 | + |
| 155 | + $installer = $this->createExtensionInstaller($filesystem); |
| 156 | + $installer->update($this->repository, $initial, $target); |
| 157 | + |
| 158 | + $this->setExpectedException('InvalidArgumentException'); |
| 159 | + $installer->update($this->repository, $initial, $target); |
| 160 | + } |
99 | 161 | } |
0 commit comments