|
44 | 44 |
|
45 | 45 | class FlexTest extends TestCase |
46 | 46 | { |
| 47 | + public function tearDown(): void |
| 48 | + { |
| 49 | + @unlink(__DIR__.'/Fixtures/symfony.lock'); |
| 50 | + } |
| 51 | + |
47 | 52 | public function testPostInstall() |
48 | 53 | { |
49 | 54 | $data = [ |
@@ -124,6 +129,56 @@ public function testActivateLoadsClasses() |
124 | 129 | $this->assertTrue(class_exists(Response::class, false)); |
125 | 130 | } |
126 | 131 |
|
| 132 | + public function testContribRecipeNotApprovedIsRemovedFromLock() |
| 133 | + { |
| 134 | + $data = [ |
| 135 | + 'manifests' => [ |
| 136 | + 'contrib/package' => [ |
| 137 | + 'manifest' => [ |
| 138 | + 'bundles' => [ |
| 139 | + 'Contrib\\Package\\ContribBundle' => ['all'], |
| 140 | + ], |
| 141 | + ], |
| 142 | + 'origin' => 'contrib/package:1.0@github.com/symfony/recipes-contrib:main', |
| 143 | + 'is_contrib' => true, |
| 144 | + ], |
| 145 | + ], |
| 146 | + 'locks' => [ |
| 147 | + 'contrib/package' => [ |
| 148 | + 'recipe' => [ |
| 149 | + 'repo' => 'github.com/symfony/recipes-contrib', |
| 150 | + 'version' => '1.0', |
| 151 | + ], |
| 152 | + 'version' => '1.0.0', |
| 153 | + ], |
| 154 | + ], |
| 155 | + ]; |
| 156 | + |
| 157 | + // Non-interactive mode with allow-contrib disabled (BufferIO is non-interactive by default) |
| 158 | + $io = new BufferIO('', OutputInterface::VERBOSITY_VERBOSE); |
| 159 | + |
| 160 | + $package = new Package('contrib/package', '1.0.0', '1.0.0'); |
| 161 | + $rootPackage = $this->mockRootPackage([]); // no allow-contrib |
| 162 | + |
| 163 | + $downloader = $this->mockDownloader($data); |
| 164 | + $configurator = $this->getMockBuilder(Configurator::class)->disableOriginalConstructor()->getMock(); |
| 165 | + // Recipe should NOT be installed |
| 166 | + $configurator->expects($this->never())->method('install'); |
| 167 | + |
| 168 | + $lock = new Lock(__DIR__.'/Fixtures/symfony.lock'); |
| 169 | + $composer = $this->mockComposer($this->mockLocker(), $rootPackage); |
| 170 | + $flex = $this->mockFlexCustom($io, $composer, $configurator, $downloader, $lock); |
| 171 | + |
| 172 | + $flex->record($this->mockPackageEvent($package)); |
| 173 | + $flex->install($this->mockFlexEvent()); |
| 174 | + $this->assertFalse($lock->has('contrib/package'), 'Recipe lock entry has been removed'); |
| 175 | + |
| 176 | + // Verify the warning message was displayed |
| 177 | + $output = $io->getOutput(); |
| 178 | + $this->assertStringContainsString('IGNORING', $output); |
| 179 | + $this->assertStringContainsString('contrib/package', $output); |
| 180 | + } |
| 181 | + |
127 | 182 | /** |
128 | 183 | * @dataProvider getPackagesForAutoDiscovery |
129 | 184 | */ |
|
0 commit comments