addProvider(new Address($faker)); $this->faker = $faker; } public function testPostCodeIsValid() { $main = '[1-9]{1}[0-9]{2}[0,1,4,5,9]{1}'; $pattern = "/^($main)|($main-[0-9]{3})+$/"; $postcode = $this->faker->postcode(); $this->assertSame(preg_match($pattern, $postcode), 1, $postcode); } }