FFM = new FF_Meta(new MockDataService()); $this->FFM->reinit_external_data_service(new MockDataService()); } /* some very basic things */ function test_basic_json_parsing() { $json = file_get_contents(__DIR__.'/example_ffhh.json'); $data = json_decode($json, $assoc = true); $this->assertArrayHasKey('name', $data); $this->assertArrayHasKey('state', $data); $this->assertArrayHasKey('location', $data); $this->assertArrayHasKey('services', $data); } function test_externaldata_mock() { $ed = new MockDataService(); $url_dir = 'https://raw.githubusercontent.com/freifunk/directory.api.freifunk.net/master/directory.json'; $url_ff = 'http://meta.hamburg.freifunk.net/ffhh.json'; $url_inv = 'http://meta.hamburg.freifunk.net/invalid.txt'; // verify that $ed->get does not read the URLs above, but local example_*.json files $data_ff = $ed->get($url_ff); $this->assertArrayHasKey('name', $data_ff); $this->assertArrayHasKey('state', $data_ff); $this->assertArrayHasKey('location', $data_ff); $this->assertArrayHasKey('services', $data_ff); $data_dir = $ed->get($url_dir); $this->assertArrayHasKey('hamburg', $data_dir); $this->assertEquals(2, count($data_dir)); $data_inv = $ed->get($url_inv); $this->assertEquals(0, count($data_inv)); } /* the aux. classes */ function test_ff_directory() { $dir = new FF_Directory(new MockDataService()); $valid = $dir->get_url_by_city('hamburg'); $invalid = $dir->get_url_by_city('jena'); $this->assertTrue(!!$valid); $this->assertTrue(!$invalid); } /** * @expectedException PHPUnit_Framework_Error */ function test_ff_community_invalid() { $data = array(); $comm = new FF_Community($data); } function test_ff_community_empty() { $data = array('location' => array()); $comm = new FF_Community($data); $this->assertEmpty($comm->street); $this->assertEmpty($comm->name); $string = $comm->format_address(); $this->assertEquals('', $string); } function test_ff_community_filled() { $data = array('location' => array( 'address' => array( 'Name' => 'some_name', 'Street' => 'some_street', 'Zipcode' => 'some_zip' ), 'city' => 'some_city', 'lon' => 'some_lon', 'lat' => 'some_lat', )); $comm = new FF_Community($data); $this->assertEquals('some_name', $comm->name); $this->assertEquals('some_street', $comm->street); $this->assertEquals('some_zip', $comm->zip); $this->assertEquals('some_city', $comm->city); $this->assertEquals('some_lon', $comm->lon); $this->assertEquals('some_lat', $comm->lat); $string = $comm->format_address(); $this->assertEquals('
some_name
some_street
some_zip some_city
Dienst | Beschreibung | Freifunk URI | Internet URI | '. '
---|---|---|---|
jabber | chat | xmpp://jabber.local | '. 'xmpp://jabber.example.org |