|
@@ 96-113 (lines=18) @@
|
| 93 |
|
$contents .= ' ' . str_replace( "\n", "\n ", json_encode( $data['object'], $jsonFlags ) ) . "\n"; |
| 94 |
|
$contents .= " ~~~~~~~~\n"; |
| 95 |
|
} |
| 96 |
|
if ( isset( $data['changelog'] ) ) { |
| 97 |
|
if ( isset( $data['parse-exception'] ) ) { |
| 98 |
|
$this->assertInstanceOf( Exception::class, $data['parse-exception'] ); |
| 99 |
|
$contents .= "\n## Expected exception from `parse()`\n"; |
| 100 |
|
$contents .= " ~~~~~~~~text parse-exception\n"; |
| 101 |
|
$contents .= ' ' . get_class( $data['parse-exception'] ) . "\n"; |
| 102 |
|
$contents .= ' ' . str_replace( "\n", "\n ", $data['parse-exception']->getMessage() ) . "\n"; |
| 103 |
|
$contents .= " ~~~~~~~~\n"; |
| 104 |
|
} elseif ( isset( $data['parse-output'] ) && ! ( isset( $data['object'] ) && $data['object'] == $data['parse-output'] ) ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
| 105 |
|
$this->assertInstanceOf( Changelog::class, $data['parse-output'] ); |
| 106 |
|
$contents .= "\n## Expected output from `parse()`\n"; |
| 107 |
|
$contents .= " ~~~~~~~~json parse-output\n"; |
| 108 |
|
$contents .= ' ' . str_replace( "\n", "\n ", json_encode( $data['parse-output'], $jsonFlags ) ) . "\n"; |
| 109 |
|
$contents .= " ~~~~~~~~\n"; |
| 110 |
|
} elseif ( ! isset( $data['object'] ) ) { |
| 111 |
|
$this->fail( 'At least one of "object", "parse-output", or "parse-exception" is required when "changelog" is given.' ); |
| 112 |
|
} |
| 113 |
|
} |
| 114 |
|
if ( isset( $data['object'] ) ) { |
| 115 |
|
if ( isset( $data['format-exception'] ) ) { |
| 116 |
|
$this->assertInstanceOf( Exception::class, $data['format-exception'] ); |
|
@@ 114-131 (lines=18) @@
|
| 111 |
|
$this->fail( 'At least one of "object", "parse-output", or "parse-exception" is required when "changelog" is given.' ); |
| 112 |
|
} |
| 113 |
|
} |
| 114 |
|
if ( isset( $data['object'] ) ) { |
| 115 |
|
if ( isset( $data['format-exception'] ) ) { |
| 116 |
|
$this->assertInstanceOf( Exception::class, $data['format-exception'] ); |
| 117 |
|
$contents .= "\n## Expected exception from `format()`\n"; |
| 118 |
|
$contents .= " ~~~~~~~~text format-exception\n"; |
| 119 |
|
$contents .= ' ' . get_class( $data['format-exception'] ) . "\n"; |
| 120 |
|
$contents .= ' ' . str_replace( "\n", "\n ", $data['format-exception']->getMessage() ) . "\n"; |
| 121 |
|
$contents .= " ~~~~~~~~\n"; |
| 122 |
|
} elseif ( isset( $data['format-output'] ) && ! ( isset( $data['changelog'] ) && $data['changelog'] == $data['format-output'] ) ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
| 123 |
|
$this->assertIsString( $data['format-output'] ); |
| 124 |
|
$contents .= "\n## Expected output from `format()`\n"; |
| 125 |
|
$contents .= " ~~~~~~~~markdown format-output\n"; |
| 126 |
|
$contents .= ' ' . str_replace( "\n", "\n ", $data['format-output'] ) . "\n"; |
| 127 |
|
$contents .= " ~~~~~~~~\n"; |
| 128 |
|
} elseif ( ! isset( $data['changelog'] ) ) { |
| 129 |
|
$this->fail( 'At least one of "changelog", "format-output", or "format-exception" is required when "object" is given.' ); |
| 130 |
|
} |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
file_put_contents( $filename, $contents ); |
| 134 |
|
} |