|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace spec\PHPCR\Shell\Console\Wizard; |
| 4 | + |
| 5 | +use PhpSpec\ObjectBehavior; |
| 6 | +use Prophecy\Argument; |
| 7 | +use Symfony\Component\Console\Helper\DialogHelper; |
| 8 | +use PHPCR\Shell\Console\Wizard\WizardInterface; |
| 9 | +use PHPCR\Shell\Console\Helper\ProfileHelper; |
| 10 | +use Symfony\Component\Console\Input\InputInterface; |
| 11 | +use Symfony\Component\Console\Output\OutputInterface; |
| 12 | +use PHPCR\Shell\Transport\SessionConfig; |
| 13 | +use PHPCR\Shell\Config\Profile; |
| 14 | +use PHPCR\Shell\Transport\TransportConfig; |
| 15 | + |
| 16 | +class ProfileWizardSpec extends ObjectBehavior |
| 17 | +{ |
| 18 | + function it_is_initializable() |
| 19 | + { |
| 20 | + $this->shouldHaveType('PHPCR\Shell\Console\Wizard\ProfileWizard'); |
| 21 | + } |
| 22 | + |
| 23 | + function let( |
| 24 | + DialogHelper $dialogHelper, |
| 25 | + ProfileHelper $profileHelper, |
| 26 | + WizardInterface $connectionWizard |
| 27 | + ) |
| 28 | + { |
| 29 | + $this->beConstructedWith( |
| 30 | + $dialogHelper, |
| 31 | + $profileHelper, |
| 32 | + $connectionWizard |
| 33 | + ); |
| 34 | + } |
| 35 | + |
| 36 | + |
| 37 | + function it_should_return_a_config_object_for_a_named_profile( |
| 38 | + InputInterface $input, |
| 39 | + OutputInterface $output, |
| 40 | + Profile $profile, |
| 41 | + ProfileHelper $profileHelper, |
| 42 | + DialogHelper $dialogHelper |
| 43 | + ) |
| 44 | + { |
| 45 | + $profileHelper->getProfileNames()->willReturn(array( |
| 46 | + 'profile1', 'profile2' |
| 47 | + )); |
| 48 | + |
| 49 | + $output->writeln('(0) Use: profile1')->shouldBeCalled(); |
| 50 | + $output->writeln('(1) Use: profile2')->shouldBeCalled(); |
| 51 | + $output->writeln('(c) Create a new profile')->shouldBeCalled(); |
| 52 | + |
| 53 | + $dialogHelper->ask($output, 'Enter a choice: ')->willReturn('0'); |
| 54 | + |
| 55 | + $profileHelper->getProfile('profile1')->willReturn($profile); |
| 56 | + $profileHelper->getProfileNames()->willReturn(array( |
| 57 | + 'profile1', 'profile2' |
| 58 | + )); |
| 59 | + |
| 60 | + $this->run($input, $output)->shouldReturn($profile); |
| 61 | + } |
| 62 | + |
| 63 | + function it_should_create_a_new_profile( |
| 64 | + InputInterface $input, |
| 65 | + OutputInterface $output, |
| 66 | + Profile $profile, |
| 67 | + ProfileHelper $profileHelper, |
| 68 | + DialogHelper $dialogHelper, |
| 69 | + TransportConfig $transportConfig, |
| 70 | + WizardInterface $connectionWizard |
| 71 | + ) |
| 72 | + { |
| 73 | + $profileHelper->getProfileNames()->willReturn(array()); |
| 74 | + |
| 75 | + $output->writeln('(c) Create a new profile')->shouldBeCalled(); |
| 76 | + $dialogHelper->ask($output, 'Enter a choice: ')->willReturn('c'); |
| 77 | + $dialogHelper->ask($output, 'Enter name for new profile: ')->willReturn('test'); |
| 78 | + $connectionWizard->run($input, $output)->willReturn(array()); |
| 79 | + $profileHelper->createNewProfile('test')->willReturn($profile); |
| 80 | + |
| 81 | + $this->run($input, $output)->shouldReturn($profile); |
| 82 | + } |
| 83 | +} |
0 commit comments