|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace spec\PHPCR\Shell\Config; |
| 4 | + |
| 5 | +use PhpSpec\ObjectBehavior; |
| 6 | +use Prophecy\Argument; |
| 7 | +use PHPCR\Shell\Console\Helper\ConfigHelper; |
| 8 | +use PHPCR\Shell\Config\Profile; |
| 9 | +use Symfony\Component\Filesystem\Filesystem; |
| 10 | + |
| 11 | +class ProfileLoaderSpec extends ObjectBehavior |
| 12 | +{ |
| 13 | + function let( |
| 14 | + ConfigHelper $configHelper, |
| 15 | + Filesystem $filesystem |
| 16 | + ) |
| 17 | + { |
| 18 | + $configHelper->getConfigDir()->willReturn(__DIR__); |
| 19 | + $this->beConstructedWith($configHelper, $filesystem); |
| 20 | + } |
| 21 | + |
| 22 | + function it_is_initializable() |
| 23 | + { |
| 24 | + $this->shouldHaveType('PHPCR\Shell\Config\ProfileLoader'); |
| 25 | + } |
| 26 | + |
| 27 | + function it_should_list_profile_names() |
| 28 | + { |
| 29 | + $this->getProfileNames()->shouldReturn(array( |
| 30 | + 'one', 'two' |
| 31 | + )); |
| 32 | + } |
| 33 | + |
| 34 | + function it_should_load_data_into_a_given_profile( |
| 35 | + Profile $profile, |
| 36 | + Filesystem $filesystem |
| 37 | + ) |
| 38 | + { |
| 39 | + $profile->getName()->willReturn('one'); |
| 40 | + $profile->set('transport', array( |
| 41 | + 'name' => 'foobar', |
| 42 | + 'bar_foo' => 'barfoo', |
| 43 | + 'foo_bar' => 'foobar', |
| 44 | + ))->shouldBeCalled(); |
| 45 | + $profile->set('phpcr', array( |
| 46 | + 'username' => 'username', |
| 47 | + 'password' => 'password', |
| 48 | + 'workspace' => 'default', |
| 49 | + ))->shouldBeCalled(); |
| 50 | + |
| 51 | + $this->loadProfile($profile); |
| 52 | + } |
| 53 | + |
| 54 | + function it_should_save_a_given_profile( |
| 55 | + Profile $profile, |
| 56 | + Filesystem $filesystem |
| 57 | + ) |
| 58 | + { |
| 59 | + $profile->getName()->willReturn('newprofile'); |
| 60 | + $profile->toArray()->willReturn(array( |
| 61 | + 'transport' => array( |
| 62 | + 'name' => 'test_transport', |
| 63 | + 'option1' => 'value1', |
| 64 | + ), |
| 65 | + 'phpcr' => array( |
| 66 | + 'username' => 'daniel', |
| 67 | + 'password' => 'leech', |
| 68 | + ), |
| 69 | + )); |
| 70 | + $filesystem->dumpFile(Argument::type('string'), <<<EOT |
| 71 | +transport: |
| 72 | + name: test_transport |
| 73 | + option1: value1 |
| 74 | +phpcr: |
| 75 | + username: daniel |
| 76 | + password: leech |
| 77 | +
|
| 78 | +EOT |
| 79 | + , 0600)->shouldBeCalled(); |
| 80 | + $this->saveProfile($profile); |
| 81 | + } |
| 82 | +} |
0 commit comments