Beispiel #1
0
 public static function set($client, $user)
 {
     $remote = new RemoteUser(['provider' => RemoteUser::toProvider($client->getId()), 'remoteid' => $client->getUserAttributes()['id'], 'client_id' => $user->obj_id]);
     if (!$remote->save()) {
         throw new InvalidCallException('failed set RemoteUser');
     }
     return $user;
 }
 public function testConnectFailsToConnectNewAccount()
 {
     RemoteUser::shouldReceive('connect')->once()->andThrow(new RestGalleries\Exception\AuthException('Invalid credentials'));
     $this->call('POST', 'users');
     $this->assertRedirectedTo('users');
     $this->assertSessionHas('message', 'Invalid credentials');
 }
 public function testReturnCorrectAttributeData()
 {
     $stub = Mockery::mock('PullAutomaticallyGalleries\\RemoteApi\\RemoteApiModelInterface')->shouldReceive('connect')->with('')->andReturn($this->userStub)->getMock();
     Test::double('RemoteUser', ['newModel' => $stub]);
     $user = RemoteUser::connect('DummyHost', '');
     assertThat($user->id, containsString('dummyhost_1'));
     assertThat($user->realname, is(equalTo($this->userStub['realname'])));
     assertThat($user->username, is(equalTo($this->userStub['username'])));
     assertThat($user->url, is(equalTo($this->userStub['url'])));
     assertThat($user->credentials, is(equalTo($this->userStub['credentials'])));
     assertThat($user->host, is(equalTo('DummyHost')));
 }