protected function updateZipCode(Municipality $municipality, $id, $name)
 {
     $zipCode = ZipCode::find($id);
     if (is_null($zipCode)) {
         $zipCode = new ZipCode(['id' => $id, 'name' => $name]);
         $municipality->zip_codes()->save($zipCode);
         $this->added++;
     } else {
         $zipCode->setAttribute('name', $name);
         $this->checkDirty($zipCode);
         $zipCode->save();
     }
 }
 public function testFindMunicipalityArray()
 {
     $county = \NorwegianZipCodes\Models\County::create(['id' => 1, 'name' => 'TestCounty']);
     $county->municipalities()->create(['id' => '0101', 'name' => 'Akershus']);
     $county->municipalities()->create(['id' => '0102', 'name' => 'Østfold']);
     $this->assertCount(2, Municipality::find(['0101', '0102']));
 }
 /**
  * This test does real calls and checks that the database is filled
  *
  * @group live
  */
 public function testCommandAddsZipCodes()
 {
     $this->assertEquals(0, ZipCode::count());
     $this->assertEquals(0, Municipality::count());
     $this->artisan->call('zip_codes:update');
     $this->assertEquals('oppdal', strtolower(ZipCode::find('7340')->name));
     $this->assertEquals('oppdal', strtolower(Municipality::find('1634')->name));
     $this->assertnotEquals(0, ZipCode::count());
     $this->assertnotEquals(0, Municipality::count());
 }