SelfUpdateTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. require_once __DIR__ . DIRECTORY_SEPARATOR . 'BaseCommandRunner.php';
  3. class SelfUpdateTest extends BaseCommandRunner
  4. {
  5. const COMMAND_CLASS = '\Codeception\Command\SelfUpdate';
  6. public function testHasUpdate()
  7. {
  8. $this->setUpCommand('2.1.2', ['2.1.0-beta', '2.1.2', '2.1.3', '2.2.0-RC2']);
  9. $this->execute();
  10. $this->assertContains('Codeception version 2.1.2', $this->output);
  11. $this->assertContains('A newer version is available: 2.1.3', $this->output);
  12. }
  13. public function testAlreadyLatest()
  14. {
  15. $this->setUpCommand('2.1.8', ['2.1.0-beta', '2.1.7', '2.1.8', '2.2.0-RC2']);
  16. $this->execute();
  17. $this->assertContains('Codeception version 2.1.8', $this->output);
  18. $this->assertContains('You are already using the latest version.', $this->output);
  19. }
  20. /**
  21. * @param string $version
  22. * @param array $tags
  23. */
  24. protected function setUpCommand($version, $tags)
  25. {
  26. $this->makeCommand(
  27. self::COMMAND_CLASS,
  28. false,
  29. [
  30. 'getCurrentVersion' => function () use ($version) {
  31. return $version;
  32. },
  33. 'getGithubTags' => function () use ($tags) {
  34. return $tags;
  35. }
  36. ]
  37. );
  38. $this->config = [];
  39. }
  40. }