You are here

public function UpdateManagerTest::testGetAvailable in Lightning Core 8.3

Same name and namespace in other branches
  1. 8.5 tests/src/Kernel/UpdateManagerTest.php \Drupal\Tests\lightning_core\Kernel\UpdateManagerTest::testGetAvailable()
  2. 8 tests/src/Kernel/UpdateManagerTest.php \Drupal\Tests\lightning_core\Kernel\UpdateManagerTest::testGetAvailable()
  3. 8.2 tests/src/Kernel/UpdateManagerTest.php \Drupal\Tests\lightning_core\Kernel\UpdateManagerTest::testGetAvailable()
  4. 8.4 tests/src/Kernel/UpdateManagerTest.php \Drupal\Tests\lightning_core\Kernel\UpdateManagerTest::testGetAvailable()

@covers ::getAvailable

File

tests/src/Kernel/UpdateManagerTest.php, line 25

Class

UpdateManagerTest
@coversDefaultClass \Drupal\lightning_core\UpdateManager

Namespace

Drupal\Tests\lightning_core\Kernel

Code

public function testGetAvailable() {
  $discovery = $this
    ->prophesize(DiscoveryInterface::class);
  $discovery
    ->getDefinitions()
    ->willReturn([
    'fubar:1.2.1' => [
      'id' => '1.2.1',
      'provider' => 'fubar',
    ],
    'fubar:1.2.2' => [
      'id' => '1.2.2',
      'provider' => 'fubar',
    ],
    'fubar:1.2.3' => [
      'id' => '1.2.3',
      'provider' => 'fubar',
    ],
  ]);
  $this->container
    ->get('config.factory')
    ->getEditable(UpdateManager::CONFIG_NAME)
    ->set('fubar', '1.2.2')
    ->save();
  $update_manager = new UpdateManager($this->container
    ->get('container.namespaces'), $this->container
    ->get('class_resolver'), $this->container
    ->get('config.factory'), $this->container
    ->get('extension.list.module'), $discovery
    ->reveal());
  $definitions = $update_manager
    ->getAvailable();
  $this
    ->assertCount(1, $definitions);
  $this
    ->assertArrayHasKey('fubar:1.2.3', $definitions);
}