public function testNaics() { // Generate the code. $this->generator->generate($this->config); // Perform the request. require_once $this->outputDir . '/GenericNAICS.php'; $service = new GenericNAICS(); $request = new GetNAICSByIndustry('Computer Systems'); $response = $service->GetNAICSByIndustry($request); // Make sure we get a response where the actual types match expected values // and generated code comments. $this->assertTrue(get_class($response) == 'GetNAICSByIndustryResponse'); $this->assertAttributeTypeConsistency('bool', 'GetNAICSByIndustryResult', $response); $this->assertAttributeInternalType('object', 'NAICSData', $response); $this->assertAttributeTypeConsistency('object', 'NAICSData', $response); $this->assertAttributeTypeConsistency('int', 'Records', $response->NAICSData); $this->assertAttributeInternalType('object', 'NAICSData', $response->NAICSData); // $response->NAICSData->NAICSData should a NAICS but is a stdClass. // TODO: Fix inconsistencies between actual type and DocBlock declaration. // $this->assertAttributeTypeConsistency('object', 'NAICSData', $response->NAICSData); $this->assertAttributeTypeConsistency('array', 'NAICS', $response->NAICSData->NAICSData); $naicsArray = $response->NAICSData->NAICSData->NAICS; foreach ($naicsArray as $naics) { $this->assertAttributeTypeConsistency('string', 'NAICSCode', $naics); $this->assertAttributeTypeConsistency('string', 'Title', $naics); $this->assertAttributeTypeConsistency('string', 'IndustryDescription', $naics); } }
/** * @vcr NaicsTest_testNaics */ public function testNaics() { // Perform the request. require_once $this->outputDir . '/GenericNAICS.php'; $service = new \GenericNAICS(); $request = new \GetNAICSByIndustry('Computer Systems'); try { $response = $service->GetNAICSByIndustry($request); // Make sure we get a response where the actual types match expected values // and generated code comments. $this->assertTrue(get_class($response) == 'GetNAICSByIndustryResponse'); $this->assertAttributeTypeConsistency('bool', 'GetNAICSByIndustryResult', $response); $this->assertAttributeInternalType('object', 'NAICSData', $response); $this->assertAttributeTypeConsistency('object', 'NAICSData', $response); $this->assertAttributeTypeConsistency('int', 'Records', $response->NAICSData); $this->assertAttributeInternalType('object', 'NAICSData', $response->NAICSData); // $response->NAICSData->NAICSData should a NAICS but is a stdClass. // TODO: Fix inconsistencies between actual type and DocBlock declaration. // $this->assertAttributeTypeConsistency('object', 'NAICSData', $response->NAICSData); $this->assertAttributeTypeConsistency('array', 'NAICS', $response->NAICSData->NAICSData); $naicsArray = $response->NAICSData->NAICSData->NAICS; foreach ($naicsArray as $naics) { $this->assertAttributeTypeConsistency('string', 'NAICSCode', $naics); $this->assertAttributeTypeConsistency('string', 'Title', $naics); $this->assertAttributeTypeConsistency('string', 'IndustryDescription', $naics); } } catch (SoapFault $e) { // If an exception is thrown it should be due to a timeout. We cannot // guard against this when calling an external service. $this->assertContains('timeout', $e->getMessage()); } }
/** * @vcr NaicsTest_testSingleNaics */ public function testSingleNaics() { $service = new \GenericNAICS(); // Requesting a specific ID should be a sure way to only return a single result. $request = new \GetNAICSByID('54151'); $response = $service->GetNaicsByID($request); // Even if there is a single result there should be an ArrayOfNaics object with an array of NAICS attribute. // This ensures that the DocBlock is still valid. The is handled as the SOAP_SINGLE_ELEMENT_ARRAYS feature is // enabled by default. $this->assertAttributeTypeConsistency('array', 'NAICS', $response->getNAICSData()->getNAICSData()); }