public function testAddProperties() { $request = $this->getMockBuilder('\\Zumba\\VanillaJsConnect\\Request')->disableOriginalConstructor()->getMock(); $user = $this->getMockBuilder('\\Zumba\\VanillaJsConnect\\User')->disableOriginalConstructor()->getMock(); $config = $this->getMockBuilder('\\Zumba\\VanillaJsConnect\\Config')->disableOriginalConstructor()->getMock(); $user->method('toArray')->will($this->returnValue(['name' => 'Foo', 'photourl' => 'imgur'])); $config->method('getSecret')->will($this->returnValue('cake')); $config->method('getClientID')->will($this->returnValue('Bar007')); $response = new Response($request, $user, $config); $response->addProperties(['test' => 'more', 'cake' => 'lie']); $queryArray = ['cake' => 'lie', 'name' => 'Foo', 'photourl' => 'imgur', 'test' => 'more']; $signature = md5(http_build_query($queryArray, NULL, '&') . 'cake'); $expectedResult = json_encode(['cake' => 'lie', 'name' => 'Foo', 'photourl' => 'imgur', 'test' => 'more', 'client_id' => 'Bar007', 'signature' => $signature]); $this->assertEquals($expectedResult, (string) $response); }
/** * Sets variables. Default is '' * * @param Request $request * @param User $user * @param Config $config */ public function __construct(Request $request, User $user, Config $config = null) { parent::__construct($request, $user); $this->name = $user->getName(); $this->photoUrl = $user->getPhotoUrl(); $this->signedIn = $this->isSignedIn(); }