class UpdateManagerTest in Lightning Core 8
Same name in this branch
- 8 tests/src/Unit/UpdateManagerTest.php \Drupal\Tests\lightning_core\Unit\UpdateManagerTest
- 8 tests/src/Kernel/UpdateManagerTest.php \Drupal\Tests\lightning_core\Kernel\UpdateManagerTest
Same name and namespace in other branches
- 8.5 tests/src/Unit/UpdateManagerTest.php \Drupal\Tests\lightning_core\Unit\UpdateManagerTest
- 8.2 tests/src/Unit/UpdateManagerTest.php \Drupal\Tests\lightning_core\Unit\UpdateManagerTest
- 8.3 tests/src/Unit/UpdateManagerTest.php \Drupal\Tests\lightning_core\Unit\UpdateManagerTest
- 8.4 tests/src/Unit/UpdateManagerTest.php \Drupal\Tests\lightning_core\Unit\UpdateManagerTest
@coversDefaultClass \Drupal\lightning_core\UpdateManager
@group lightning @group lightning_core
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\lightning_core\Unit\UpdateManagerTest
Expanded class hierarchy of UpdateManagerTest
File
- tests/
src/ Unit/ UpdateManagerTest.php, line 15
Namespace
Drupal\Tests\lightning_core\UnitView source
class UpdateManagerTest extends UnitTestCase {
/**
* @covers ::toSemanticVersion
*
* @dataProvider providerSemanticVersion
*/
public function testSemanticVersion($drupal_version, $semantic_version) {
$this
->assertSame($semantic_version, UpdateManager::toSemanticVersion($drupal_version));
}
public function providerSemanticVersion() {
return [
[
'8.x-1.12',
'1.12.0',
],
[
'8.x-1.2-alpha3',
'1.2.0-alpha3',
],
[
'8.x-2.7-beta3',
'2.7.0-beta3',
],
[
'8.x-1.42-rc1',
'1.42.0-rc1',
],
[
'8.x-1.x-dev',
'1.x-dev',
],
// This is a weird edge case only used by the Lightning profile.
[
'8.x-3.001',
'3.001.0',
],
];
}
/**
* @covers ::getTasks
*/
public function testGetTasks() {
$update_manager = new TestUpdateManager(new \ArrayIterator(), $this
->createMock('\\Drupal\\Core\\DependencyInjection\\ClassResolverInterface'), $this
->createMock('\\Drupal\\Core\\Config\\ConfigFactoryInterface'));
$tasks = $update_manager
->getTasks(new TestUpdateHandler());
$tasks = iterator_to_array($tasks);
$this
->assertCount(2, $tasks);
$io = $this
->prophesize(StyleInterface::class);
$io
->confirm('Can you trip like I do?')
->willReturn(TRUE);
$io
->success('Dude, sweet!')
->shouldBeCalled();
$tasks[0]
->execute($io
->reveal());
$io
->confirm('Why would you do this?')
->willReturn(FALSE);
$io
->error('Oh, the humanity!')
->shouldNotBeCalled();
$tasks[1]
->execute($io
->reveal());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
protected | function | 340 | |
UpdateManagerTest:: |
public | function | ||
UpdateManagerTest:: |
public | function | @covers ::getTasks | |
UpdateManagerTest:: |
public | function | @covers ::toSemanticVersion |