PluginProbe
Packeta / 2.1
Packeta v2.1
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
← All changes | tests/Module/Options/OptionsProviderTest.php +1 -94 trunk2.1 View file →
@@ -10,10 +10,8 @@
10 10 use Packetery\Module\Options\OptionsProvider;
11 11 use PHPUnit\Framework\TestCase;
12 12
13 13 class OptionsProviderTest extends TestCase {
14 - private const DUMMY_NONSENSE_VALUE = 'nonsense';
15 -
16 14 public static function dimensionsUnitProvider(): array {
17 15 return [
18 16 [
19 17 'unit' => 'cm',
@@ -176,9 +174,9 @@
176 174 'inputValue' => '',
177 175 'expectedValue' => false,
178 176 ],
179 177 [
180 - 'inputValue' => self::DUMMY_NONSENSE_VALUE,
178 + 'inputValue' => 'nonsense',
181 179 'expectedValue' => true,
182 180 ],
183 181 ];
184 182 }
@@ -195,72 +193,8 @@
195 193
196 194 $this->assertSame( $expectedValue, $provider->isWcCarrierConfigEnabledNullable() );
197 195 }
198 196
199 - public static function autoEmailInfoInsertionEnabledProvider(): array {
200 - return [
201 - [
202 - 'inputValue' => true,
203 - 'expectedValue' => true,
204 - ],
205 - [
206 - 'inputValue' => false,
207 - 'expectedValue' => false,
208 - ],
209 - [
210 - 'inputValue' => null,
211 - 'expectedValue' => true,
212 - ],
213 - [
214 - 'inputValue' => 1,
215 - 'expectedValue' => true,
216 - ],
217 - [
218 - 'inputValue' => 0,
219 - 'expectedValue' => false,
220 - ],
221 - [
222 - 'inputValue' => '1',
223 - 'expectedValue' => true,
224 - ],
225 - [
226 - 'inputValue' => '0',
227 - 'expectedValue' => false,
228 - ],
229 - [
230 - 'inputValue' => '',
231 - 'expectedValue' => false,
232 - ],
233 - [
234 - 'inputValue' => self::DUMMY_NONSENSE_VALUE,
235 - 'expectedValue' => true,
236 - ],
237 - ];
238 - }
239 -
240 - /**
241 - * @dataProvider autoEmailInfoInsertionEnabledProvider
242 - */
243 - public function testIsAutoEmailInfoInsertionEnabled( mixed $inputValue, bool $expectedValue ): void {
244 - $wpAdapterMock = $this->createMock( WpAdapter::class );
245 - $wpAdapterMock->method( 'getOption' )
246 - ->willReturn( [ 'auto_email_info_insertion' => $inputValue ] );
247 -
248 - $provider = new OptionsProvider( $wpAdapterMock );
249 -
250 - $this->assertSame( $expectedValue, $provider->isAutoEmailInfoInsertionEnabled() );
251 - }
252 -
253 - public function testIsAutoEmailInfoInsertionEnabledReturnsDefaultWhenOptionNotSet(): void {
254 - $wpAdapterMock = $this->createMock( WpAdapter::class );
255 - $wpAdapterMock->method( 'getOption' )
256 - ->willReturn( [] );
257 -
258 - $provider = new OptionsProvider( $wpAdapterMock );
259 -
260 - $this->assertSame( true, $provider->isAutoEmailInfoInsertionEnabled() );
261 - }
262 -
263 197 public function testGetPacketAutoSubmissionMappedUniqueEvents(): void {
264 198 $wpAdapterMock = $this->createMock( WpAdapter::class );
265 199 $wpAdapterMock
266 200 ->method( 'getOption' )
@@ -289,33 +223,6 @@
289 223 $provider = new OptionsProvider( $wpAdapterMock );
290 224
291 225 $result = $provider->getPacketAutoSubmissionMappedUniqueEvents();
292 226 $this->assertSame( [ 'order_paid', 'order_shipped' ], array_values( $result ) );
293 - }
294 -
295 - public function testShowConsignPasswordForZBoxDefaultsToDisabled(): void {
296 - $wpAdapterMock = $this->createMock( WpAdapter::class );
297 - $wpAdapterMock->method( 'getOption' )->willReturn( [] );
298 -
299 - $provider = new OptionsProvider( $wpAdapterMock );
300 -
301 - $this->assertFalse( $provider->isShowConsignPasswordForZBoxEnabled() );
302 - }
303 -
304 - public function testShowConsignPasswordForZBoxReadsStoredValue(): void {
305 - $wpAdapterMock = $this->createMock( WpAdapter::class );
306 - $wpAdapterMock->method( 'getOption' )
307 - ->willReturnCallback(
308 - static function ( string $key ) {
309 - if ( $key === OptionNames::PACKETERY ) {
310 - return [ 'show_consign_password_for_z_box' => true ];
311 - }
312 -
313 - return [];
314 - }
315 - );
316 -
317 - $provider = new OptionsProvider( $wpAdapterMock );
318 -
319 - $this->assertTrue( $provider->isShowConsignPasswordForZBoxEnabled() );
320 227 }
321 228 }