Page MenuHomeDevCentral

D1542.id3937.diff
No OneTemporary

D1542.id3937.diff

diff --git a/app/Phabricator/PhabricatorStory.php b/app/Phabricator/PhabricatorStory.php
--- a/app/Phabricator/PhabricatorStory.php
+++ b/app/Phabricator/PhabricatorStory.php
@@ -315,9 +315,8 @@
return "id";
}
- if (starts_with($key, "story")) {
- $key = substr($key, 5);
- $key[0] = strtolower($key[0]); // lowercase
+ if (starts_with($key, "story") && strlen($key) > 5) {
+ return lcfirst(substr($key, 5));
}
return $key;
diff --git a/tests/Phabricator/PhabricatorStoryTest.php b/tests/Phabricator/PhabricatorStoryTest.php
--- a/tests/Phabricator/PhabricatorStoryTest.php
+++ b/tests/Phabricator/PhabricatorStoryTest.php
@@ -22,4 +22,22 @@
yield ["VOID", ['foo' => 'bar']];
yield ["TASK", ['objectPHID' => 'PHID-TASK-l34fw5wievp6n6rnvpuk']];
}
+
+ /**
+ * @dataProvider provideKeys
+ */
+ public function testMapPhabricatorFeedKey ($expected, $key) {
+ $this->assertEquals(
+ $expected,
+ PhabricatorStory::mapPhabricatorFeedKey($key)
+ );
+ }
+
+ public function provideKeys () : iterable {
+ yield ['id', 'storyID'];
+ yield ['id', 'storyId'];
+ yield ['task', 'storyTask'];
+ yield ['story', 'story'];
+ yield ['', ''];
+ }
}

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 02:36 (11 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2248547
Default Alt Text
D1542.id3937.diff (1 KB)

Event Timeline