/** * @test */ public function it_returns_the_expected_results() { $expected = ['getArray', 'getObject', 'getString']; // Just does not have "get" in it $methodThatIsNotAGetter = TestFactory::mockReflectionMethod(); $methodThatIsNotAGetter->shouldReceive('getName')->withNoArgs()->andReturn('methodThatIsNotAGetter')->once(); // Has "get" in the middle of the method name $forgetMethod = TestFactory::mockReflectionMethod(); $forgetMethod->shouldReceive('getName')->withNoArgs()->andReturn('forgetMethod')->once(); // Letter after "get" is not caps $getter = TestFactory::mockReflectionMethod(); $getter->shouldReceive('getName')->withNoArgs()->andReturn('getter')->once(); $getArray = TestFactory::mockReflectionMethod(); $getArray->shouldReceive('getName')->withNoArgs()->andReturn('getArray')->once(); $getObject = TestFactory::mockReflectionMethod(); $getObject->shouldReceive('getName')->withNoArgs()->andReturn('getObject')->once(); $getString = TestFactory::mockReflectionMethod(); $getString->shouldReceive('getName')->withNoArgs()->andReturn('getString')->once(); $reflection_mock = TestFactory::mockReflectionClass(); $reflection_mock->shouldReceive('getMethods')->with(ReflectionMethod::IS_PUBLIC)->andReturn([$methodThatIsNotAGetter, $forgetMethod, $getter, $getArray, $getObject, $getString])->once(); $this->reflecter_mock->shouldReceive('reflect')->with('SomeResultClass')->andReturn($reflection_mock)->once(); $response = $this->getter->process('SomeResultClass'); $this->assertEquals($expected, $response); }
/** * Resolve the item from the IoC & execute the method on it * * @param array $arguments * @param array $columns * * @return \Spinen\ConnectWise\Library\Support\Collection */ public function execute(array $arguments = [], $columns = []) { $parameters = $this->get($this->getApiNamespace($this->method)); // Run through all of the keys in the argument, and call a setter on them if it exists foreach ($arguments as $argument => $value) { $setter = "set" . studly_case($argument); if (method_exists($parameters, $setter)) { $parameters->{$setter}($value); } } // Get the response from the WSDL $response = $this->get($this->getApiNamespace($this->api))->{$this->method}($parameters); // Unwrap all of the nested values that the WSDL returns $response = $this->converter->setApi($this->api)->setColumns($columns)->process($response); return $response; }
/** * @test */ public function it_set_the_time_zone_to_convert_dates() { $this->assertEquals($this->converter, $this->converter->setTimeZone('America/Kentucky/Louisville')); }