Exemplo n.º 1
0
 public function it_should_load_data_into_a_given_profile(Profile $profile, Filesystem $filesystem)
 {
     $profile->get('phpcr', 'workspace')->willReturn('default');
     $profile->getName()->willReturn('one');
     $profile->set('transport', array('name' => 'foobar', 'bar_foo' => 'barfoo', 'foo_bar' => 'foobar'))->shouldBeCalled();
     $profile->set('phpcr', array('username' => 'username', 'password' => 'password', 'workspace' => 'default'))->shouldBeCalled();
     $this->loadProfile($profile);
 }
Exemplo n.º 2
0
 public function loadProfile(Profile $profile)
 {
     $path = $this->getProfilePath($profile->getName());
     if (!file_exists($path)) {
         throw new \InvalidArgumentException(sprintf('Profile "%s" does not exist, expected to find it in "%s"', $profile->getName(), $path));
     }
     $contents = file_get_contents($path);
     $data = Yaml::parse($contents);
     if (isset($data['transport'])) {
         $profile->set('transport', $data['transport']);
     }
     $profileWorkspace = $profile->get('phpcr', 'workspace');
     if (isset($data['phpcr'])) {
         $profile->set('phpcr', $data['phpcr']);
     }
     // workspace argument overrides profile workspace
     if ($profileWorkspace && $profileWorkspace !== 'default') {
         $profile->set('phpcr', 'workspace', $profileWorkspace);
     }
 }