You are here

public function UpdateManagerTest::testGetTasks in Lightning Core 8

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

@covers ::getTasks

File

tests/src/Unit/UpdateManagerTest.php, line 41

Class

UpdateManagerTest
@coversDefaultClass \Drupal\lightning_core\UpdateManager

Namespace

Drupal\Tests\lightning_core\Unit

Code

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());
}