|
35 | 35 | (phpstan--plist-to-alist '(:a 1 :b 2)))) |
36 | 36 | (should (equal nil (phpstan--plist-to-alist nil)))) |
37 | 37 |
|
| 38 | +;;; JSON parsing |
| 39 | + |
| 40 | +(ert-deftest phpstan-test-parse-json-false-is-nil () |
| 41 | + "JSON false and null read as nil, not a truthy symbol. |
| 42 | +`ignorable' is read in a truthy context, so `false' must be nil." |
| 43 | + (with-temp-buffer |
| 44 | + (insert "{\"a\":false,\"b\":null,\"c\":true}") |
| 45 | + (let ((data (phpstan--parse-json (current-buffer)))) |
| 46 | + (should-not (plist-get data :a)) |
| 47 | + (should-not (plist-get data :b)) |
| 48 | + (should (eq t (plist-get data :c)))))) |
| 49 | + |
| 50 | +(ert-deftest phpstan-test-update-ignorable-skips-non-ignorable () |
| 51 | + "Only ignorable messages feed `phpstan--ignorable-errors'. |
| 52 | +A non-ignorable message (\"ignorable\":false) must not be offered to |
| 53 | +`phpstan-insert-ignore'." |
| 54 | + (with-temp-buffer |
| 55 | + (insert (concat "{\"files\":{\"/x\":{\"messages\":[" |
| 56 | + "{\"message\":\"parse error\",\"line\":1,\"ignorable\":false," |
| 57 | + "\"identifier\":\"ignore.parseError\"}," |
| 58 | + "{\"message\":\"undefined\",\"line\":2,\"ignorable\":true," |
| 59 | + "\"identifier\":\"variable.undefined\"}]}}}")) |
| 60 | + (let ((errors (phpstan--plist-to-alist |
| 61 | + (plist-get (phpstan--parse-json (current-buffer)) :files)))) |
| 62 | + (phpstan-update-ignorebale-errors-from-json-buffer errors) |
| 63 | + (should (equal '((2 "variable.undefined")) phpstan--ignorable-errors))))) |
| 64 | + |
38 | 65 | ;;; Container runtime detection |
39 | 66 |
|
40 | 67 | (ert-deftest phpstan-test-container-runtime-command () |
|
0 commit comments