From ba0a8069c4e834e16d88d81fbd7c27b2fe4e83a3 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 24 Feb 2024 23:46:54 -0500 Subject: [PATCH] Normalize local node hostname across API fixtures - This was causing the fixture data to be wrongly "repaired" in Model\User::getOwnerDataById because of a mismatch between the local base URL and the fixture-provided self contact URL --- tests/DatabaseTestTrait.php | 2 +- tests/Util/Database/StaticDatabase.php | 2 +- tests/datasets/api.fixture.php | 95 +++++++++---------- .../Module/Api/Friendica/NotificationTest.php | 2 +- 4 files changed, 46 insertions(+), 55 deletions(-) diff --git a/tests/DatabaseTestTrait.php b/tests/DatabaseTestTrait.php index 79ff5ae162..6e4c073d5f 100644 --- a/tests/DatabaseTestTrait.php +++ b/tests/DatabaseTestTrait.php @@ -35,7 +35,7 @@ trait DatabaseTestTrait // Rollbacks every DB usage (in case the test couldn't call tearDown) StaticDatabase::statRollback(); // Rollback the first, outer transaction just 2 be sure - StaticDatabase::getGlobConnection()->rollBack(); + StaticDatabase::getGlobConnection()->rollback(); // Start the first, outer transaction StaticDatabase::getGlobConnection()->beginTransaction(); } diff --git a/tests/Util/Database/StaticDatabase.php b/tests/Util/Database/StaticDatabase.php index 9713861f56..92d241f9cd 100644 --- a/tests/Util/Database/StaticDatabase.php +++ b/tests/Util/Database/StaticDatabase.php @@ -211,7 +211,7 @@ class StaticDatabase extends Database { if (isset(self::$staticConnection)) { while (self::$staticConnection->getTransactionDepth() > 0) { - self::$staticConnection->rollBack(); + self::$staticConnection->rollback(); } } } diff --git a/tests/datasets/api.fixture.php b/tests/datasets/api.fixture.php index 6c90ffded2..783b3fc920 100644 --- a/tests/datasets/api.fixture.php +++ b/tests/datasets/api.fixture.php @@ -25,16 +25,6 @@ use Friendica\Model\Item; use Friendica\Model\Notification; return [ - // Empty these tables - 'profile_field', - 'permissionset', - 'cache', - 'conversation', - 'pconfig', - 'photo', - 'workerqueue', - 'mail', - 'post-delivery-data', 'gserver' => [ [ 'url' => 'https://friendica.local', @@ -94,22 +84,22 @@ return [ ], [ 'id' => 42, - 'uri' => 'http://localhost/profile/selfcontact', + 'uri' => 'https://friendica.local/profile/selfcontact', 'guid' => '42', ], [ 'id' => 43, - 'uri' => 'http://localhost/profile/othercontact', + 'uri' => 'https://friendica.local/profile/othercontact', 'guid' => '43', ], [ 'id' => 44, - 'uri' => 'http://localhost/profile/friendcontact', + 'uri' => 'https://friendica.local/profile/friendcontact', 'guid' => '44', ], [ 'id' => 46, - 'uri' => 'http://localhost/profile/mutualcontact', + 'uri' => 'https://friendica.local/profile/mutualcontact', 'guid' => '46', ], [ @@ -126,9 +116,9 @@ return [ 'name' => 'Self contact', 'nick' => 'selfcontact', 'self' => 1, - 'nurl' => 'http://localhost/profile/selfcontact', - 'url' => 'http://localhost/profile/selfcontact', - 'notify' => 'http://localhost/friendica/inbox', + 'nurl' => 'http://friendica.local/profile/selfcontact', + 'url' => 'https://friendica.local/profile/selfcontact', + 'notify' => 'https://friendica.local/friendica/inbox', 'about' => 'User used in tests', 'prvkey' => "-----BEGIN RSA PRIVATE KEY-----\nMIICXgIBAAKBgQDVqxF9kIgtgRL0+q+jTi578FA1r1+crEmlYc0pdxcbmmrhjuRc\nrK1gX3r0mnP25fkHzG+6CAjgbDBRFM1/RXBCyp/KHVks7eQ4yr4MxTRlsxo5qf2o\nnbyNzM7Q+LZhFhe/yIoGN/fuEjlqBE98IfPOrUjsQPX240vGNXIkfLiAWwIDAQAB\nAoGBAIwuiPIdggqAtWQ+mD8HCx5LQwSFw6/xpPu5F7ZNqL52aAsGCbL3o2QoIG4c\na1qf9Ot16BNgNBqxQF3hzRTkBMrKYlmNTUkwJXun/zjQJq2JvOlcrSuXlIucUjs4\nXekVN25aYPHrX9m2FEIUwZTb4UYXbR80KbIDI53BkQ6EwSbpAkEA7aO49CR2Hf1Y\n1d2GaUI/Z0wvbj//+t0Kg0bPt16ca8KVjEQQA5ylsDaiw510jDz9NBQxSOk6If23\nUeRixc1RDQJBAOYtN4YnPM1Zfp6IxXlqMCc+xUWRTPEPFt+WpG+v79koNamAeA6o\nZzTl92hl58IqSdbgojeE2zXWQRvlimFMLQcCQQCV6jND0byyLqFcSeQBg0l8YROK\n+dUC7W80YfeoNod3c8nkMwvnO2tLPyxvO2XLEq6prBNra7bAus5rWyj0oBIBAkEA\n1EvUMFm0TLpEfLgtWuTD8Q6GKLnxO0ztjd+FXrXpBGN/ywyArxRHzJRmctW6wmz6\nmcOqGobhIHCysKYv0bnOtQJAc2M5RwlASHH4jGJzXgt3nboyiJfufM0RV9iry3ho\nCXQRWAONKoLqnsfC6qNP8OzY8FMJcwmPWj7Q/6z6yLBFTA==\n-----END RSA PRIVATE KEY-----", 'pubkey' => "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVqxF9kIgtgRL0+q+jTi578FA1\nr1+crEmlYc0pdxcbmmrhjuRcrK1gX3r0mnP25fkHzG+6CAjgbDBRFM1/RXBCyp/K\nHVks7eQ4yr4MxTRlsxo5qf2onbyNzM7Q+LZhFhe/yIoGN/fuEjlqBE98IfPOrUjs\nQPX240vGNXIkfLiAWwIDAQAB\n-----END PUBLIC KEY-----", @@ -137,6 +127,7 @@ return [ 'rel' => Contact::FOLLOWER, 'network' => Protocol::DFRN, 'location' => 'DFRN', + 'baseurl' => 'https://friendica.local', ], // Having the same name and nick allows us to test // the fallback to api_get_nick() in api_get_user() @@ -147,9 +138,9 @@ return [ 'name' => 'othercontact', 'nick' => 'othercontact', 'self' => 0, - 'nurl' => 'http://localhost/profile/othercontact', - 'url' => 'http://localhost/profile/othercontact', - 'notify' => 'http://localhost/friendica/inbox', + 'nurl' => 'http://friendica.local/profile/othercontact', + 'url' => 'https://friendica.local/profile/othercontact', + 'notify' => 'https://friendica.local/friendica/inbox', 'pending' => 0, 'blocked' => 0, 'rel' => Contact::NOTHING, @@ -163,9 +154,9 @@ return [ 'name' => 'Friend contact', 'nick' => 'friendcontact', 'self' => 0, - 'nurl' => 'http://localhost/profile/friendcontact', - 'url' => 'http://localhost/profile/friendcontact', - 'notify' => 'http://localhost/friendica/inbox', + 'nurl' => 'http://friendica.local/profile/friendcontact', + 'url' => 'https://friendica.local/profile/friendcontact', + 'notify' => 'https://friendica.local/friendica/inbox', 'pending' => 0, 'blocked' => 0, 'rel' => Contact::SHARING, @@ -179,9 +170,9 @@ return [ 'name' => 'Friend contact', 'nick' => 'friendcontact', 'self' => 0, - 'nurl' => 'http://localhost/profile/friendcontact', - 'url' => 'http://localhost/profile/friendcontact', - 'notify' => 'http://localhost/friendica/inbox', + 'nurl' => 'http://friendica.local/profile/friendcontact', + 'url' => 'https://friendica.local/profile/friendcontact', + 'notify' => 'https://friendica.local/friendica/inbox', 'pending' => 0, 'blocked' => 0, 'rel' => Contact::SHARING, @@ -195,9 +186,9 @@ return [ 'name' => 'Mutual contact', 'nick' => 'mutualcontact', 'self' => 0, - 'nurl' => 'http://localhost/profile/mutualcontact', - 'url' => 'http://localhost/profile/mutualcontact', - 'notify' => 'http://localhost/friendica/inbox', + 'nurl' => 'http://friendica.local/profile/mutualcontact', + 'url' => 'https://friendica.local/profile/mutualcontact', + 'notify' => 'https://friendica.local/friendica/inbox', 'pending' => 0, 'blocked' => 0, 'rel' => Contact::FRIEND, @@ -211,9 +202,9 @@ return [ 'name' => 'Mutual contact', 'nick' => 'mutualcontact', 'self' => 0, - 'nurl' => 'http://localhost/profile/mutualcontact', - 'url' => 'http://localhost/profile/mutualcontact', - 'notify' => 'http://localhost/friendica/inbox', + 'nurl' => 'http://friendica.local/profile/mutualcontact', + 'url' => 'https://friendica.local/profile/mutualcontact', + 'notify' => 'https://friendica.local/friendica/inbox', 'pending' => 0, 'blocked' => 0, 'rel' => Contact::SHARING, @@ -227,9 +218,9 @@ return [ 'name' => 'Self contact', 'nick' => 'selfcontact', 'self' => 0, - 'nurl' => 'http://localhost/profile/selfcontact', - 'url' => 'http://localhost/profile/selfcontact', - 'notify' => 'http://localhost/friendica/inbox', + 'nurl' => 'http://friendica.local/profile/selfcontact', + 'url' => 'https://friendica.local/profile/selfcontact', + 'notify' => 'https://friendica.local/friendica/inbox', 'about' => 'User used in tests', 'pending' => 0, 'blocked' => 0, @@ -240,15 +231,15 @@ return [ ], 'apcontact' => [ [ - "url" => "http://localhost/profile/selfcontact", + "url" => "https://friendica.local/profile/selfcontact", "uri-id" => 1, "uuid" => "42", "type" => "Person", - "following" => "http://localhost/following/selfcontact", - "followers" => "http://localhost/followers/selfcontact", - "inbox" => "http://localhost/inbox/selfcontact", - "outbox" => "http://localhost/outbox/selfcontact", - "sharedinbox" => "http://localhost/inbox", + "following" => "https://friendica.local/following/selfcontact", + "followers" => "https://friendica.local/followers/selfcontact", + "inbox" => "https://friendica.local/inbox/selfcontact", + "outbox" => "https://friendica.local/outbox/selfcontact", + "sharedinbox" => "https://friendica.local/inbox", "manually-approve" => 1, "discoverable" => 0, "nick" => "selfcontact", @@ -256,7 +247,7 @@ return [ "about" => "User used in tests", "xmpp" => null, "matrix" => null, - "photo" => "http://localhost/photo/profile/admin.jpeg", + "photo" => "https://friendica.local/photo/profile/admin.jpeg", "header" => null, "addr" => "selfcontact@localhost", "alias" => null, @@ -313,32 +304,32 @@ return [ [ 'uri-id' => 1, 'body' => 'Parent status', - 'plink' => 'http://localhost/display/1', + 'plink' => 'https://friendica.local/display/1', ], [ 'uri-id' => 2, 'body' => 'Reply', - 'plink' => 'http://localhost/display/2', + 'plink' => 'https://friendica.local/display/2', ], [ 'uri-id' => 3, 'body' => 'Other user status', - 'plink' => 'http://localhost/display/3', + 'plink' => 'https://friendica.local/display/3', ], [ 'uri-id' => 4, 'body' => 'Friend user reply', - 'plink' => 'http://localhost/display/4', + 'plink' => 'https://friendica.local/display/4', ], [ 'uri-id' => 5, 'body' => '[share]Shared status[/share]', - 'plink' => 'http://localhost/display/5', + 'plink' => 'https://friendica.local/display/5', ], [ 'uri-id' => 6, 'body' => 'Friend user status', - 'plink' => 'http://localhost/display/6', + 'plink' => 'https://friendica.local/display/6', ], [ 'uri-id' => 7, @@ -366,7 +357,7 @@ return [ 'suscipit aut facilis ut inventore omnis exercitationem quo magnam ' . 'consequatur maxime aut illum soluta quaerat natus unde aspernatur ' . 'et sed beatae nihil ullam temporibus corporis ratione blanditiis', - 'plink' => 'http://localhost/display/6', + 'plink' => 'https://friendica.local/display/6', ], [ 'uri-id' => 100, @@ -919,12 +910,12 @@ return [ 'id' => 1, 'type' => 8, 'name' => 'Friend contact', - 'url' => 'http://localhost/profile/friendcontact', - 'photo' => 'http://localhost/', + 'url' => 'https://friendica.local/profile/friendcontact', + 'photo' => 'https://friendica.local/', 'date' => '2020-01-01 12:12:02', 'msg' => 'A test reply from an item', 'uid' => 42, - 'link' => 'http://localhost/display/1', + 'link' => 'https://friendica.local/display/1', 'iid' => 4, 'seen' => 0, 'verb' => \Friendica\Protocol\Activity::POST, diff --git a/tests/src/Module/Api/Friendica/NotificationTest.php b/tests/src/Module/Api/Friendica/NotificationTest.php index 73e0bca6f9..21c1c3629b 100644 --- a/tests/src/Module/Api/Friendica/NotificationTest.php +++ b/tests/src/Module/Api/Friendica/NotificationTest.php @@ -62,7 +62,7 @@ class NotificationTest extends ApiTest $assertXml = << - + XML;