Beispiel #1
0
 public function testGetRegionCodeRegionFailure()
 {
     $this->address->setData(['region' => 1, 'region_id' => 1, 'country_id' => 1]);
     $this->regionFactoryMock->expects($this->once())->method('create')->willReturn($this->regionMock);
     $this->regionMock->expects($this->once())->method('load')->with(1)->willReturn($this->regionMock);
     $this->regionMock->expects($this->once())->method('getCountryId')->willReturn(2);
     $this->regionMock->expects($this->never())->method('getCode');
     $this->assertEquals(null, $this->address->getRegionCode());
 }
 public function testBeforeSave()
 {
     $regionId = '23';
     $countryId = '67';
     $this->object->expects($this->once())->method('getData')->with('region')->willReturn($regionId);
     $this->object->expects($this->once())->method('getCountryId')->willReturn($countryId);
     $this->regionFactory->expects($this->once())->method('create')->willReturn($this->region);
     $this->region->expects($this->once())->method('load')->with($regionId)->willReturnSelf();
     $this->region->expects($this->atLeastOnce())->method('getId')->willReturn($regionId);
     $this->region->expects($this->once())->method('getCountryId')->willReturn($countryId);
     $this->object->expects($this->once())->method('setRegionId')->with($regionId)->willReturnSelf();
     $this->region->expects($this->once())->method('getName')->willReturn('Region name');
     $this->object->expects($this->once())->method('setRegion')->with('Region name');
     $this->model->beforeSave($this->object);
 }