Re: Re: [PEPr] +1 for Web Services::Services_Libravatar

From: Date: Sun, 26 Jun 2011 17:37:53 +0000
Subject: Re: Re: [PEPr] +1 for Web Services::Services_Libravatar
References: 1 2 3 4  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-54345@lists.php.net to get a copy of this message
On Sat, Jun 25, 2011 at 9:08 AM, till <till@php.net> wrote: > > >> 4) srvGet() - or rather getSrvRecord() - should utilize Net_DNS2. > >> > > > > > > Oh for deity's sake. Why? > > I'm yet to see a convincing argument as to why I should add a dependency > on > > an additional library to handle what is provided in *core php* > > by dns_get_record. That is, other than to please those who think an EOL'd > > php version for Windows servers is a valid SOE, or dependency for > dependency > > sake. > > Then strictly speaking, we all shouldn't be using any libs at all > since it's all possible with core PHP. Right? Or maybe not. (I'm being > sarcastic, of course.) > I agree there is no need for the Net_DNS2 dependency when the function is is available in PHP. However, I also agree the call to the function should be abstracted so that you can minimize the amount of code that is mocked in a unit test. For example: $srv = dns_get_record($subdomain . $domain, DNS_SRV); Could be changed to: $srv = $this->_dnsGetRecord($dubdomain . $domain, DNS_SRV); And that method would simply call the dns_get_record() function and return the results. This might seem odd to someone that hasn't done unit tests with mocking, but it allows you to minimize the amount of dependency injection you do, and is really easy to do. When you do write the test, you'll want to make sure you test all possible error cases from dns_get_record().

« previous php.pear.dev (#54345) next »