objectManager = new ObjectManagerHelper($this); $this->directoryHelperMock = $this->createMock(HelperData::class); $this->model = $this->objectManager->getObject( DirectoryData::class, [ 'directoryHelper' => $this->directoryHelperMock ] ); } /** * Test getSectionData() function */ public function testGetSectionData() { $regions = [ 'US' => [ 'TX' => [ 'code' => 'TX', 'name' => 'Texas' ] ] ]; $testCountryInfo = $this->objectManager->getObject(Country::class); $testCountryInfo->setData('country_id', 'US'); $testCountryInfo->setData('iso2_code', 'US'); $testCountryInfo->setData('iso3_code', 'USA'); $testCountryInfo->setData('name_default', 'United States of America'); $testCountryInfo->setData('name_en_US', 'United States of America'); $countries = ['US' => $testCountryInfo]; $this->directoryHelperMock->expects($this->any()) ->method('getRegionData') ->willReturn($regions); $this->directoryHelperMock->expects($this->any()) ->method('getCountryCollection') ->willReturn($countries); /* Assert result */ $this->assertEquals( [ 'US' => [ 'name' => 'United States of America', 'regions' => [ 'TX' => [ 'code' => 'TX', 'name' => 'Texas' ] ] ] ], $this->model->getSectionData() ); } }