コード例 #1
0
function test_writePostion()
{
    appendTestMessage(NEW_LINE_LOG . " >> Tests writing of single position..." . NEW_LINE_LOG);
    appendTestMessage("Prepare: Create new user");
    $ret = checkUser("dUser", "dPassword");
    if ($ret) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Check parameter lat");
    $ret = writePostion('', '', '', '', '', '', '', '', '', '');
    if (!$ret) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Check parameter lon");
    $ret = writePostion('', '', '47.50457163540115', '', '', '', '', '', '', '');
    if (!$ret) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Prepare: Create new user");
    $ret = checkUser("dUser", "dPassword");
    if ($ret) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get tracks (individually 1) for user (no positions yet)");
    $ret = getLastPostionsAndTracksIndividually('');
    if (isNullOrEmptyString($ret)) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get tracks (individually 2) for user (no positions yet)");
    $ret = getLastPostionsAndTracksIndividually('dUser');
    if (isNullOrEmptyString($ret)) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get tracks (individually 3) for user (no positions yet)");
    $ret = getLastPostionsAndTracksIndividually('dUser=2013-03-03 15:48:47.484', 'true');
    if (isNullOrEmptyString($ret)) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Test helper function to write the postion.csv > new");
    $ret = writePositionFile('dUser', 'test;test;test');
    if ($ret) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    $testDateTime = getDateForTimezoneOffset('dUser', '', false);
    appendTestMessage("Write single position");
    $csvLine = 'lat=47.50457163540115;lon=11.071390274487026;bearing=171.61432;speed=0.7065948;altitude=1067.652498529502;accuracy=6.0;time=' . $testDateTime;
    $ret = writePositionFile('dUser', $csvLine);
    if ($ret) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Write lat and lon");
    $ret = writePostion('dUser', '', '42.50457163540115', '11.071390274487026', '', '', '', '', '2012-03-03T15:48:47.484', 'true');
    if ($ret) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get tracks (individually 1) for user  (one position yet) no track for today");
    $ret = getLastPostionsAndTracksIndividually('dUser');
    $expectedTracks = '[positions]' . PHP_EOL . 'user=dUser;lat=42.50457163540115;lon=11.071390274487026;time=2012-03-03T15:48:47.484';
    if ($ret == $expectedTracks) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get tracks (individually 2) for user  (one position yet) - track excluded because of time");
    $ret = getLastPostionsAndTracksIndividually('dUser=2012-03-03T15:48:47.4841');
    $expectedTracks = "[positions]" . PHP_EOL . 'user=dUser;lat=42.50457163540115;lon=11.071390274487026;time=2012-03-03T15:48:47.484';
    if ($ret == $expectedTracks) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    $testDate = getDateForTimezoneOffset('dUser', '', true);
    appendTestMessage("Write lat and lon");
    $ret = writePostion('dUser', '', '42.50457163540115', '11.071390274487026', '', '', '', '', $testDate . 'T15:48:47.484', 'true');
    if ($ret) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    $today = getDateForTimezoneOffset('dUser', '', true);
    $gpxFileName = $today . '.csv';
    appendTestMessage("Check for a data file (gpx) for this user");
    $ret = getUsersForDataFileName('dUser', $gpxFileName);
    if ($ret == 'dUser') {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    // TODO: New
    appendTestMessage("Check for a data file (gpx) for this user. But exclude the user");
    $ret = getUsersForDataFileName('dUser', $gpxFileName, 'dUser');
    if ($ret == '') {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("View single position");
    $csvLine0 = 'lat=42.50457163540115;lon=11.071390274487026;time=' . $testDate . 'T15:48:47.484';
    $ret = getPosition('dUser');
    if ($ret === $csvLine0) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("View single position (parameter = getGroupPostions");
    $ret = getGroupPostions('dUser');
    $expectedLine = 'user=dUser;' . $csvLine0;
    if ($ret === $expectedLine) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Write lat and lon");
    $ret = writePostion('dUser', 'cGroup_changed', '43.50457163540115', '11.071390274487026', '171.61432', '0.7065948', '1067.652498529502', '6.0', $testDate . 'T15:48:48.484', 'true');
    if ($ret) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get tracks individually for user (omit tracks)");
    $ret = getLastPostionsAndTracksIndividually('dUser', 'false');
    $expectedTracks = '[positions]' . PHP_EOL . 'user=dUser;lat=43.50457163540115;lon=11.071390274487026;bearing=171.61432;speed=0.7065948;altitude=1067.652498529502;accuracy=6.0;time=' . $testDate . 'T15:48:48.484';
    if ($ret == $expectedTracks) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get tracks individually for user (omit tracks)");
    $ret = getLastPostionsAndTracksIndividually('dUser', 'no');
    $expectedTracks = '[positions]' . PHP_EOL . 'user=dUser;lat=43.50457163540115;lon=11.071390274487026;bearing=171.61432;speed=0.7065948;altitude=1067.652498529502;accuracy=6.0;time=' . $testDate . 'T15:48:48.484';
    if ($ret == $expectedTracks) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get tracks individually for user (two positions yet no last time given)");
    $ret = getLastPostionsAndTracksIndividually('dUser', 'true');
    $expectedTracks = '[positions]' . PHP_EOL . 'user=dUser;lat=43.50457163540115;lon=11.071390274487026;bearing=171.61432;speed=0.7065948;altitude=1067.652498529502;accuracy=6.0;time=' . $testDate . 'T15:48:48.484' . PHP_EOL . '[track-dUser]' . PHP_EOL . 'lat=42.50457163540115;lon=11.071390274487026;time=' . $testDate . 'T15:48:47.484' . PHP_EOL . 'lat=43.50457163540115;lon=11.071390274487026;bearing=171.61432;speed=0.7065948;altitude=1067.652498529502;accuracy=6.0;time=' . $testDate . 'T15:48:48.484';
    if ($ret == $expectedTracks) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("View single position");
    $csvLine1 = 'lat=43.50457163540115;lon=11.071390274487026;bearing=171.61432;speed=0.7065948;altitude=1067.652498529502;accuracy=6.0;time=' . $testDate . 'T15:48:48.484';
    $ret = getPosition('dUser');
    if ($ret === $csvLine1) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Write empty multiline positions");
    $ret = writePostions('dUser', 'cGroup_changed', '', 'true');
    if (!$ret) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Write multiline positions");
    $csvLine2 = 'lat=44.50457163540115;lon=11.071390274487026;bearing=171.61432;speed=0.7065948;altitude=1067.652498529502;accuracy=6.0;time=' . $testDate . 'T15:54:41.484';
    $csvLine3 = 'lat=45.50457163540115;lon=11.071390274487026;bearing=171.61432;speed=0.7065948;altitude=1067.652498529502;accuracy=6.0;time=' . $testDate . 'T15:54:42.484';
    $csvLine4 = 'lat=46.50457163540115;lon=11.071390274487026;bearing=171.61432;speed=0.7065948;altitude=1067.652498529502;accuracy=6.0;time=' . $testDate . 'T15:54:43.484';
    $csvLines2_4 = $csvLine2 . PHP_EOL . $csvLine3 . PHP_EOL . $csvLine4;
    $csvLines0_4 = $csvLine0 . PHP_EOL . $csvLine1 . PHP_EOL . $csvLine2 . PHP_EOL . $csvLine3 . PHP_EOL . $csvLine4;
    $ret = writePostions('dUser', 'cGroup_changed', $csvLines2_4, 'true');
    if ($ret) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("View single position set by multiline writing");
    $ret = getPosition('dUser');
    if ($ret === $csvLine4) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get tracks individally for user (five positions yet, last time given)");
    $ret = getLastPostionsAndTracksIndividually('dUser='******'T15:48:48.484');
    $expectedTracks = "[positions]" . PHP_EOL . 'user=dUser;' . $csvLine4 . PHP_EOL . '[track-dUser]' . PHP_EOL . $csvLine2 . PHP_EOL . $csvLine3 . PHP_EOL . $csvLine4;
    if ($ret == $expectedTracks) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("List tracks");
    $ret = listTracks('dUser');
    $expectedFileName = '2012-03-03.gpx';
    if ($ret == $expectedFileName) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("List tracks");
    $ret = listTracksCSV('dUser');
    $expectedFileNames1 = $testDate . '.csv' . PHP_EOL . '2012-03-03.csv';
    $expectedFileNames2 = '2012-03-03.csv' . PHP_EOL . $testDate . '.csv';
    if ($ret === $expectedFileNames1 || $ret === $expectedFileNames2) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get track check empty parameter date");
    $ret = getTrack('dUser', '', '');
    if ($ret === $csvLines0_4) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get track");
    $ret = getTrack('dUser', $today, '');
    if ($ret === $csvLines0_4) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    // Review: This test seems to be double, see test somewhere above
    appendTestMessage("Get track after a certain line number only");
    $ret = getTrack('dUser', $today, $testDate . 'T15:48:48.484');
    if ($ret === $csvLines2_4) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get track after a certain line number (at end already)");
    $ret = getTrack('dUser', $today, $testDate . 'T15:54:43.484');
    if ($ret === '') {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get postions of group");
    $ret = getPositions('cGroup_changed');
    $expectedString = 'user=dUser;' . $csvLine4;
    if ($ret === $expectedString) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    // TODO: New
    appendTestMessage("Get postions of group. But exclude the user dUser");
    $ret = getPositions('cGroup_changed', dUser);
    if ($ret === '') {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    // Add second user with same group
    appendTestMessage("Prepare: Create new user");
    $ret = checkUser("eUser", "ePassword");
    if ($ret) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Check for a data file (gpx) for this user. A second user is in the group but without this file.");
    $ret = getUsersForDataFileName('dUser', $gpxFileName);
    if ($ret == 'dUser') {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    // TODO: New
    appendTestMessage("Check for a data file (gpx) for this user. AND exclude the user. A second user is in the group but without this file.");
    $ret = getUsersForDataFileName('dUser', $gpxFileName, 'dUser');
    if ($ret == '') {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Prepare: Write position new second user with same group");
    $csvLine5 = 'lat=47.50457163540115;lon=11.071390274487026;bearing=171.61432;speed=0.7065948;altitude=1067.652498529502;accuracy=6.0;time=' . $testDate . 'T15:54:43.484';
    $ret = writePostions('eUser', 'cGroup_changed', $csvLine5, 'true');
    if ($ret) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Check for a data file (gpx) for this user. A second user is in the group now.");
    $ret = getUsersForDataFileName('dUser', $gpxFileName);
    $expectedUsers = 'dUser' . PHP_EOL . 'eUser';
    $expectedUsers1 = 'eUser' . PHP_EOL . 'dUser';
    if ($ret == $expectedUsers || $ret == $expectedUsers1) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    // TODO: New
    appendTestMessage("Check for a data file (gpx) for this user. But exclude the user. A second user is in the group now.");
    $ret = getUsersForDataFileName('dUser', $gpxFileName, 'dUser');
    $expectedUsers = 'eUser';
    if ($ret == $expectedUsers) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get postions of the two members of the group");
    $ret = getPositions('cGroup_changed');
    $expectedPostions = 'user=dUser;' . $csvLine4 . PHP_EOL . 'user=eUser;' . $csvLine5;
    $expectedPostions1 = 'user=eUser;' . $csvLine5 . PHP_EOL . 'user=dUser;' . $csvLine4;
    if ($ret === $expectedPostions || $ret === $expectedPostions1) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    // TODO: New
    appendTestMessage("Get postions of the two members of the group. Exclude user eUser");
    $ret = getPositions('cGroup_changed', 'eUser');
    $expectedPostions = 'user=dUser;' . $csvLine4;
    if ($ret === $expectedPostions) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get tracks individually for 2 users (last time given - 1)");
    $ret = getLastPostionsAndTracksIndividually('dUser='******'T15:48:48.484');
    $expectedTracks = "[positions]" . PHP_EOL . 'user=dUser;' . $csvLine4 . PHP_EOL . 'user=eUser;' . $csvLine5 . PHP_EOL . '[track-dUser]' . PHP_EOL . $csvLine2 . PHP_EOL . $csvLine3 . PHP_EOL . $csvLine4 . PHP_EOL . '[track-eUser]' . PHP_EOL . $csvLine5;
    $expectedTracks1 = "[positions]" . PHP_EOL . 'user=eUser;' . $csvLine5 . PHP_EOL . 'user=dUser;' . $csvLine4 . PHP_EOL . '[track-eUser]' . PHP_EOL . $csvLine5 . PHP_EOL . '[track-dUser]' . PHP_EOL . $csvLine2 . PHP_EOL . $csvLine3 . PHP_EOL . $csvLine4;
    if ($ret == $expectedTracks || $ret == $expectedTracks1) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get tracks individually for 2 users (last line given - 2)");
    $ret = getLastPostionsAndTracksIndividually('dUser='******'T15:48:48.484;eUser');
    $expectedTracks = "[positions]" . PHP_EOL . 'user=dUser;' . $csvLine4 . PHP_EOL . 'user=eUser;' . $csvLine5 . PHP_EOL . '[track-dUser]' . PHP_EOL . $csvLine2 . PHP_EOL . $csvLine3 . PHP_EOL . $csvLine4 . PHP_EOL . '[track-eUser]' . PHP_EOL . $csvLine5;
    $expectedTracks1 = "[positions]" . PHP_EOL . 'user=eUser;' . $csvLine5 . PHP_EOL . 'user=dUser;' . $csvLine4 . PHP_EOL . '[track-eUser]' . PHP_EOL . $csvLine5 . PHP_EOL . '[track-dUser]' . PHP_EOL . $csvLine2 . PHP_EOL . $csvLine3 . PHP_EOL . $csvLine4;
    if ($ret == $expectedTracks || $ret == $expectedTracks1) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get tracks individually for 2 users (last line given - 3)");
    $ret = getLastPostionsAndTracksIndividually('dUser='******'T15:48:48.484;eUser='******'T15:54:42.484');
    $expectedTracks = "[positions]" . PHP_EOL . 'user=dUser;' . $csvLine4 . PHP_EOL . 'user=eUser;' . $csvLine5 . PHP_EOL . '[track-dUser]' . PHP_EOL . $csvLine2 . PHP_EOL . $csvLine3 . PHP_EOL . $csvLine4 . PHP_EOL . '[track-eUser]' . PHP_EOL . $csvLine5;
    $expectedTracks1 = "[positions]" . PHP_EOL . 'user=eUser;' . $csvLine5 . PHP_EOL . 'user=dUser;' . $csvLine4 . PHP_EOL . '[track-eUser]' . PHP_EOL . $csvLine5 . PHP_EOL . '[track-dUser]' . PHP_EOL . $csvLine2 . PHP_EOL . $csvLine3 . PHP_EOL . $csvLine4;
    if ($ret == $expectedTracks || $ret == $expectedTracks1) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get tracks individually for 2 users (last line given - 4)");
    $ret = getLastPostionsAndTracksIndividually('dUser='******'T15:48:48.484;eUser='******'T15:54:43.484');
    $expectedTracks = "[positions]" . PHP_EOL . 'user=dUser;' . $csvLine4 . PHP_EOL . 'user=eUser;' . $csvLine5 . PHP_EOL . '[track-dUser]' . PHP_EOL . $csvLine2 . PHP_EOL . $csvLine3 . PHP_EOL . $csvLine4;
    $expectedTracks1 = "[positions]" . PHP_EOL . 'user=eUser;' . $csvLine5 . PHP_EOL . 'user=dUser;' . $csvLine4 . PHP_EOL . '[track-dUser]' . PHP_EOL . $csvLine2 . PHP_EOL . $csvLine3 . PHP_EOL . $csvLine4;
    if ($ret == $expectedTracks || $ret == $expectedTracks1) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get tracks individually for 2 users (last line given - 5)");
    $ret = getLastPostionsAndTracksIndividually('dUser='******'T15:54:43.484' . ';eUser='******'T15:54:43.484');
    $expectedTracks = "[positions]" . PHP_EOL . 'user=dUser;' . $csvLine4 . PHP_EOL . 'user=eUser;' . $csvLine5;
    $expectedTracks1 = "[positions]" . PHP_EOL . 'user=eUser;' . $csvLine5 . PHP_EOL . 'user=dUser;' . $csvLine4;
    if ($ret == $expectedTracks || $ret == $expectedTracks1) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get postions of the two members of the group (param = getGroupPostions");
    $ret = getGroupPostions('dUser');
    if ($ret === $expectedPostions || $ret === $expectedPostions1) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Util: write some csv files to create gpx (later)");
    if (test_writeGpxFromCsv()) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Create gpx from csv and list. Check eUser");
    $ret = listTracks('eUser');
    $expected1 = "2013-03-10.gpx" . PHP_EOL . "2013-03-11.gpx";
    $expected2 = "2013-03-11.gpx" . PHP_EOL . "2013-03-10.gpx";
    if ($ret == $expected1 || $ret == $expected2) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Create gpx from csv and list. Check dUser");
    $ret = listTracks('dUser');
    $expected1 = "2013-03-10.gpx" . PHP_EOL . "2012-03-03.gpx";
    $expected2 = "2012-03-03.gpx" . PHP_EOL . "2013-03-10.gpx";
    if ($ret == $expected1 || $ret == $expected2) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Write multiline positions with different dates");
    $csvLine6 = 'lat=44.50457163540115;lon=11.071390274487026;bearing=171.61432;speed=0.7065948;altitude=1067.652498529502;accuracy=6.0;time=2012-04-03T15:54:41.484';
    $csvLine7 = 'lat=45.50457163540115;lon=11.071390274487026;bearing=171.61432;speed=0.7065948;altitude=1067.652498529502;accuracy=6.0;time=' . $testDate . 'T15:54:44.484';
    $csvLine8 = 'lat=46.50457163540115;lon=11.071390274487026;bearing=171.61432;speed=0.7065948;altitude=1067.652498529502;accuracy=6.0;time=' . $testDate . 'T15:54:45.484';
    $csvLines6_8 = $csvLine6 . PHP_EOL . $csvLine7 . PHP_EOL . $csvLine8;
    $csvLines0_8_dUser = $csvLine0 . PHP_EOL . $csvLine1 . PHP_EOL . $csvLine2 . PHP_EOL . $csvLine3 . PHP_EOL . $csvLine4 . PHP_EOL . $csvLine7 . PHP_EOL . $csvLine8;
    $ret = writePostions('dUser', 'cGroup_changed', $csvLines6_8, 'true');
    if ($ret) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get tracks individually for 2 users all lines");
    $ret = getLastPostionsAndTracksIndividually('dUser;eUser');
    $expectedTracks = "[positions]" . PHP_EOL . 'user=dUser;' . $csvLine8 . PHP_EOL . 'user=eUser;' . $csvLine5 . PHP_EOL . '[track-dUser]' . PHP_EOL . $csvLines0_8_dUser . PHP_EOL . '[track-eUser]' . PHP_EOL . $csvLine5;
    $expectedTracks1 = "[positions]" . PHP_EOL . 'user=eUser;' . $csvLine5 . PHP_EOL . 'user=dUser;' . $csvLine8 . PHP_EOL . '[track-eUser]' . PHP_EOL . $csvLine5 . PHP_EOL . '[track-dUser]' . PHP_EOL . $csvLines0_8_dUser;
    if ($ret == $expectedTracks || $ret == $expectedTracks1) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get tracks individually for 2 users all lines");
    $ret = getLastPostionsAndTracksIndividually('dUser='******'T15:54:44.484;eUser');
    $expectedTracks = "[positions]" . PHP_EOL . 'user=dUser;' . $csvLine8 . PHP_EOL . 'user=eUser;' . $csvLine5 . PHP_EOL . '[track-dUser]' . PHP_EOL . $csvLine8 . PHP_EOL . '[track-eUser]' . PHP_EOL . $csvLine5;
    $expectedTracks1 = "[positions]" . PHP_EOL . 'user=eUser;' . $csvLine5 . PHP_EOL . 'user=dUser;' . $csvLine8 . PHP_EOL . '[track-eUser]' . PHP_EOL . $csvLine5 . PHP_EOL . '[track-dUser]' . PHP_EOL . $csvLine8;
    if ($ret == $expectedTracks || $ret == $expectedTracks1) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("List tracks");
    $ret = listTracksCSV('dUser');
    $expectedFileNames1 = $testDate . '.csv' . PHP_EOL . '2012-03-03.csv' . PHP_EOL . '2012-04-03.csv' . PHP_EOL . '2013-03-10.csv';
    $searchString = '/' . $testDate . '.csv/i';
    if (preg_match($searchString, $ret, $matches)) {
        $foundTime = $matches[0];
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    $searchString = '/2012-03-03.csv/i';
    if (preg_match($searchString, $ret, $matches)) {
        $foundTime = $matches[0];
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    $searchString = '/2012-04-03.csv/i';
    if (preg_match($searchString, $ret, $matches)) {
        $foundTime = $matches[0];
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    $searchString = '/2013-03-10.csv/i';
    if (preg_match($searchString, $ret, $matches)) {
        $foundTime = $matches[0];
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Write multiline positions with different dates and track not stored");
    $csvLine6 = 'lat=44.50457163540115;lon=11.071390274487026;bearing=171.61432;speed=0.7065948;altitude=1067.652498529502;accuracy=6.0;time=2012-04-03T15:54:41.484';
    $csvLine7 = 'lat=45.50457163540115;lon=11.071390274487026;bearing=171.61432;speed=0.7065948;altitude=1067.652498529502;accuracy=6.0;time=' . $testDate . 'T15:54:44.484';
    $csvLine8 = 'lat=46.50457163540115;lon=11.071390274487026;bearing=171.61432;speed=0.7065948;altitude=1067.652498529502;accuracy=6.0;time=' . $testDate . 'T15:54:45.484';
    $csvLine9 = 'lat=46.50457163540115;lon=11.071390274487026;bearing=171.61432;speed=0.7065948;altitude=1067.652498529502;accuracy=6.0;time=' . $testDate . 'T15:54:46.484';
    $csvLines6_9 = $csvLine6 . PHP_EOL . $csvLine7 . PHP_EOL . $csvLine8 . PHP_EOL . $csvLine9;
    $ret = writePostions('dUser', 'cGroup_changed', $csvLines6_9, 'false');
    if ($ret) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    appendTestMessage("Get tracks individually for 2 users all lines");
    $ret = getLastPostionsAndTracksIndividually('dUser;eUser');
    $expectedTracks = "[positions]" . PHP_EOL . 'user=dUser;' . $csvLine9 . PHP_EOL . 'user=eUser;' . $csvLine5 . PHP_EOL . '[track-dUser]' . PHP_EOL . $csvLines0_8_dUser . PHP_EOL . '[track-eUser]' . PHP_EOL . $csvLine5;
    $expectedTracks1 = "[positions]" . PHP_EOL . 'user=eUser;' . $csvLine5 . PHP_EOL . 'user=dUser;' . $csvLine9 . PHP_EOL . '[track-eUser]' . PHP_EOL . $csvLine5 . PHP_EOL . '[track-dUser]' . PHP_EOL . $csvLines0_8_dUser;
    if ($ret == $expectedTracks || $ret == $expectedTracks1) {
        appendTestMessage("- ok");
    } else {
        appendTestMessage("- failed");
        return false;
    }
    return true;
}
コード例 #2
0
ファイル: geo5.php プロジェクト: einervonvielen/mushrooms
    setServerResponse($users);
    return;
}
// Get all users (of a group) that have a given data file(name)
$getLastPostionsAndTracks = getParam('getLastPostionsAndTracksIndividually');
if (!isNullOrEmptyString($getLastPostionsAndTracks)) {
    // 1. Write the group if given
    $group = getParam('group');
    //	if (!isNullOrEmptyString($group)) {
    if (!writeGroupFile($user, $group)) {
        setServerError("Failed to change group for user {$user}.");
        return;
    }
    //	}
    // 2. Get positionm and tracks
    $postions = getLastPostionsAndTracksIndividually($getLastPostionsAndTracks, getParam('track'), $user);
    if (isNullOrEmptyString($postions)) {
        // 		setServerError("Failed to get last postions and tracks for $getLastPostionsAndTracks");
        // 		return;
        // It might happen that a new user has nothing on the server
        $postions = '';
    }
    setServerResponse($postions);
    return;
}
setServerError('Server does not know what to do. Give on of the following parameters: passNew (change password), groupNew (change group), remove (delete user), lat (write one position), postions (write more than one positions), getPosition (get postion of user), getPositions (get postions of group), listTracks (list tracks of user), getTrack (get single track)');
return;
/////////////////////////////////////////////////////////////////////////
// Helpers
/////////////////////////////////////////////////////////////////////////
function setServerResponse($message)