public function testDefaultAddressInCaseOfException() { $url = "http://php.net/feed.atom"; $address = new AddressSetter(); try { $address->setAddress($url); $adress = $address->getAddressUri(); } catch (Exception $ex) { $adress = $address->getAddressUri(); } $this->assertEquals($url, $adress); }
public function addnewchannel(\Illuminate\Http\Request $request) { $msg = ''; $this->validate($request, ['uri' => 'required|url']); $address = new AddressSetter(); if (empty($request->get('uri'))) { return redirect('feedrss')->with('msg', 'Can not add empty url'); } else { try { $address->setAddress($request->get('uri')); } catch (\Exception $ex) { $msg = $ex->getMessage() . ' Default url was setted.'; } } $rss = new DownloadRss($address->getAddressUri()); $channel = new RssChannel($address->getAddressUri()); try { $channel->getIdChannel(); $msg .= 'These address exist! Doesnt add new channel'; } catch (\Exception $ex) { $rss->getFeed($channel->insertIntoTable()); } return redirect('feedrss')->with('msg', $msg); }