()
| 538 | |
| 539 | #[test] |
| 540 | fn parse_fixable_flag() { |
| 541 | let json_fixable = r#"{ |
| 542 | "totals": {"errors": 1, "warnings": 0, "fixable": 1}, |
| 543 | "files": { |
| 544 | "/project/src/Foo.php": { |
| 545 | "errors": 1, |
| 546 | "warnings": 0, |
| 547 | "messages": [ |
| 548 | { |
| 549 | "message": "Expected 1 space after comma.", |
| 550 | "source": "Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma", |
| 551 | "severity": 5, |
| 552 | "fixable": true, |
| 553 | "type": "ERROR", |
| 554 | "line": 10, |
| 555 | "column": 15 |
| 556 | } |
| 557 | ] |
| 558 | } |
| 559 | } |
| 560 | }"#; |
| 561 | let path = Path::new("/project/src/Foo.php"); |
| 562 | let diags = parse_phpcs_json(json_fixable, path).unwrap(); |
| 563 | assert_eq!(diags.len(), 1); |
| 564 | assert_eq!(diags[0].data, Some(serde_json::json!({ "fixable": true }))); |
| 565 | |
| 566 | let json_not_fixable = r#"{ |
| 567 | "totals": {"errors": 1, "warnings": 0, "fixable": 0}, |
| 568 | "files": { |
| 569 | "/project/src/Foo.php": { |
| 570 | "errors": 1, |
| 571 | "warnings": 0, |
| 572 | "messages": [ |
| 573 | { |
| 574 | "message": "Class name must be declared in StudlyCaps.", |
| 575 | "source": "PSR1.Classes.ClassDeclaration.MissingNamespace", |
| 576 | "severity": 5, |
| 577 | "fixable": false, |
| 578 | "type": "ERROR", |
| 579 | "line": 3, |
| 580 | "column": 7 |
| 581 | } |
| 582 | ] |
| 583 | } |
| 584 | } |
| 585 | }"#; |
| 586 | let diags = parse_phpcs_json(json_not_fixable, path).unwrap(); |
| 587 | assert_eq!(diags.len(), 1); |
| 588 | assert_eq!(diags[0].data, Some(serde_json::json!({ "fixable": false }))); |
| 589 | } |
| 590 | |
| 591 | #[test] |
| 592 | fn parse_single_file_entry_always_matches() { |
nothing calls this directly
no test coverage detected