|
@@ 129-146 (lines=18) @@
|
| 126 |
|
$contents .= $this->indent( json_encode( $data['object'], $jsonFlags ) ) . "\n"; |
| 127 |
|
$contents .= " ~~~~~~~~\n"; |
| 128 |
|
} |
| 129 |
|
if ( isset( $data['changelog'] ) ) { |
| 130 |
|
if ( isset( $data['parse-exception'] ) ) { |
| 131 |
|
$this->assertInstanceOf( Exception::class, $data['parse-exception'] ); |
| 132 |
|
$contents .= "\n## Expected exception from `parse()`\n"; |
| 133 |
|
$contents .= " ~~~~~~~~text parse-exception\n"; |
| 134 |
|
$contents .= ' ' . get_class( $data['parse-exception'] ) . "\n"; |
| 135 |
|
$contents .= $this->indent( $data['parse-exception']->getMessage() ) . "\n"; |
| 136 |
|
$contents .= " ~~~~~~~~\n"; |
| 137 |
|
} elseif ( isset( $data['parse-output'] ) && ! ( isset( $data['object'] ) && $data['object'] == $data['parse-output'] ) ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
| 138 |
|
$this->assertInstanceOf( Changelog::class, $data['parse-output'] ); |
| 139 |
|
$contents .= "\n## Expected output from `parse()`\n"; |
| 140 |
|
$contents .= " ~~~~~~~~json parse-output\n"; |
| 141 |
|
$contents .= $this->indent( json_encode( $data['parse-output'], $jsonFlags ) ) . "\n"; |
| 142 |
|
$contents .= " ~~~~~~~~\n"; |
| 143 |
|
} elseif ( ! isset( $data['object'] ) ) { |
| 144 |
|
$this->fail( 'At least one of "object", "parse-output", or "parse-exception" is required when "changelog" is given.' ); |
| 145 |
|
} |
| 146 |
|
} |
| 147 |
|
if ( isset( $data['object'] ) ) { |
| 148 |
|
if ( isset( $data['format-exception'] ) ) { |
| 149 |
|
$this->assertInstanceOf( Exception::class, $data['format-exception'] ); |
|
@@ 147-164 (lines=18) @@
|
| 144 |
|
$this->fail( 'At least one of "object", "parse-output", or "parse-exception" is required when "changelog" is given.' ); |
| 145 |
|
} |
| 146 |
|
} |
| 147 |
|
if ( isset( $data['object'] ) ) { |
| 148 |
|
if ( isset( $data['format-exception'] ) ) { |
| 149 |
|
$this->assertInstanceOf( Exception::class, $data['format-exception'] ); |
| 150 |
|
$contents .= "\n## Expected exception from `format()`\n"; |
| 151 |
|
$contents .= " ~~~~~~~~text format-exception\n"; |
| 152 |
|
$contents .= ' ' . get_class( $data['format-exception'] ) . "\n"; |
| 153 |
|
$contents .= $this->indent( $data['format-exception']->getMessage() ) . "\n"; |
| 154 |
|
$contents .= " ~~~~~~~~\n"; |
| 155 |
|
} elseif ( isset( $data['format-output'] ) && ! ( isset( $data['changelog'] ) && $data['changelog'] == $data['format-output'] ) ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
| 156 |
|
$this->assertIsString( $data['format-output'] ); |
| 157 |
|
$contents .= "\n## Expected output from `format()`\n"; |
| 158 |
|
$contents .= " ~~~~~~~~markdown format-output\n"; |
| 159 |
|
$contents .= $this->indent( $data['format-output'] ) . "\n"; |
| 160 |
|
$contents .= " ~~~~~~~~\n"; |
| 161 |
|
} elseif ( ! isset( $data['changelog'] ) ) { |
| 162 |
|
$this->fail( 'At least one of "changelog", "format-output", or "format-exception" is required when "object" is given.' ); |
| 163 |
|
} |
| 164 |
|
} |
| 165 |
|
|
| 166 |
|
$this->assertNotFalse( file_put_contents( $filename, $contents ) ); |
| 167 |
|
} |