Changeset 62248
- Timestamp:
- 04/21/2026 12:33:43 PM (3 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/ai-client/wpAiClientPromptBuilder.php
r62101 r62248 189 189 190 190 $this->assertInstanceOf( RequestOptions::class, $request_options ); 191 $this->assert Equals( 30, $request_options->getTimeout() );191 $this->assertSame( 30.0, $request_options->getTimeout() ); 192 192 } 193 193 … … 211 211 212 212 $this->assertInstanceOf( RequestOptions::class, $request_options ); 213 $this->assert Equals( 45, $request_options->getTimeout() );213 $this->assertSame( 45.0, $request_options->getTimeout() ); 214 214 } 215 215 … … 402 402 $this->assertCount( 1, $messages ); 403 403 $this->assertInstanceOf( Message::class, $messages[0] ); 404 $this->assert Equals( 'Hello, world!', $messages[0]->getParts()[0]->getText() );404 $this->assertSame( 'Hello, world!', $messages[0]->getParts()[0]->getText() ); 405 405 } 406 406 … … 419 419 $this->assertCount( 1, $messages ); 420 420 $this->assertInstanceOf( Message::class, $messages[0] ); 421 $this->assert Equals( 'Test message', $messages[0]->getParts()[0]->getText() );421 $this->assertSame( 'Test message', $messages[0]->getParts()[0]->getText() ); 422 422 } 423 423 … … 480 480 $this->assertCount( 1, $messages ); 481 481 $this->assertInstanceOf( Message::class, $messages[0] ); 482 $this->assert Equals( 'Hello from array', $messages[0]->getParts()[0]->getText() );482 $this->assertSame( 'Hello from array', $messages[0]->getParts()[0]->getText() ); 483 483 } 484 484 … … 498 498 499 499 $this->assertCount( 1, $messages ); 500 $this->assert Equals( 'Some text', $messages[0]->getParts()[0]->getText() );500 $this->assertSame( 'Some text', $messages[0]->getParts()[0]->getText() ); 501 501 } 502 502 … … 516 516 $parts = $messages[0]->getParts(); 517 517 $this->assertCount( 2, $parts ); 518 $this->assert Equals( 'Initial text', $parts[0]->getText() );519 $this->assert Equals( ' Additional text', $parts[1]->getText() );518 $this->assertSame( 'Initial text', $parts[0]->getText() ); 519 $this->assertSame( ' Additional text', $parts[1]->getText() ); 520 520 } 521 521 … … 538 538 $file = $messages[0]->getParts()[0]->getFile(); 539 539 $this->assertInstanceOf( File::class, $file ); 540 $this->assert Equals( 'data:image/png;base64,' . $base64, $file->getDataUri() );541 $this->assert Equals( 'image/png', $file->getMimeType() );540 $this->assertSame( 'data:image/png;base64,' . $base64, $file->getDataUri() ); 541 $this->assertSame( 'image/png', $file->getMimeType() ); 542 542 } 543 543 … … 559 559 $file = $messages[0]->getParts()[0]->getFile(); 560 560 $this->assertInstanceOf( File::class, $file ); 561 $this->assert Equals( 'https://example.com/image.jpg', $file->getUrl() );562 $this->assert Equals( 'image/jpeg', $file->getMimeType() );561 $this->assertSame( 'https://example.com/image.jpg', $file->getUrl() ); 562 $this->assertSame( 'image/jpeg', $file->getMimeType() ); 563 563 } 564 564 … … 581 581 $file = $messages[0]->getParts()[0]->getFile(); 582 582 $this->assertInstanceOf( File::class, $file ); 583 $this->assert Equals( 'image/jpeg', $file->getMimeType() );583 $this->assertSame( 'image/jpeg', $file->getMimeType() ); 584 584 } 585 585 … … 601 601 $file = $messages[0]->getParts()[0]->getFile(); 602 602 $this->assertInstanceOf( File::class, $file ); 603 $this->assert Equals( 'https://example.com/audio.mp3', $file->getUrl() );604 $this->assert Equals( 'audio/mpeg', $file->getMimeType() );603 $this->assertSame( 'https://example.com/audio.mp3', $file->getUrl() ); 604 $this->assertSame( 'audio/mpeg', $file->getMimeType() ); 605 605 } 606 606 … … 645 645 $parts = $messages[0]->getParts(); 646 646 $this->assertCount( 3, $parts ); 647 $this->assert Equals( 'Part 1', $parts[0]->getText() );648 $this->assert Equals( 'Part 2', $parts[1]->getText() );649 $this->assert Equals( 'Part 3', $parts[2]->getText() );647 $this->assertSame( 'Part 1', $parts[0]->getText() ); 648 $this->assertSame( 'Part 2', $parts[1]->getText() ); 649 $this->assertSame( 'Part 3', $parts[2]->getText() ); 650 650 } 651 651 … … 671 671 672 672 $this->assertCount( 3, $messages ); 673 $this->assert Equals( 'User 1', $messages[0]->getParts()[0]->getText() );674 $this->assert Equals( 'Model 1', $messages[1]->getParts()[0]->getText() );675 $this->assert Equals( 'User 2', $messages[2]->getParts()[0]->getText() );673 $this->assertSame( 'User 1', $messages[0]->getParts()[0]->getText() ); 674 $this->assertSame( 'Model 1', $messages[1]->getParts()[0]->getText() ); 675 $this->assertSame( 'User 2', $messages[2]->getParts()[0]->getText() ); 676 676 } 677 677 … … 711 711 $parts = $messages[0]->getParts(); 712 712 $this->assertCount( 3, $parts ); 713 $this->assert Equals( 'Part 1', $parts[0]->getText() );714 $this->assert Equals( 'Part 2', $parts[1]->getText() );715 $this->assert Equals( 'Part 3', $parts[2]->getText() );713 $this->assertSame( 'Part 1', $parts[0]->getText() ); 714 $this->assertSame( 'Part 2', $parts[1]->getText() ); 715 $this->assertSame( 'Part 3', $parts[2]->getText() ); 716 716 } 717 717 … … 736 736 $parts = $messages[0]->getParts(); 737 737 $this->assertCount( 3, $parts ); 738 $this->assert Equals( 'String part', $parts[0]->getText() );739 $this->assert Equals( 'Part 1', $parts[1]->getText() );740 $this->assert Equals( 'Part 2', $parts[2]->getText() );738 $this->assertSame( 'String part', $parts[0]->getText() ); 739 $this->assertSame( 'Part 1', $parts[1]->getText() ); 740 $this->assertSame( 'Part 2', $parts[2]->getText() ); 741 741 } 742 742 … … 776 776 $config = $this->get_wrapped_prompt_builder_property_value( $builder, 'modelConfig' ); 777 777 778 $this->assert Equals( 'Be helpful', $config->getSystemInstruction() );779 $this->assert Equals( 500, $config->getMaxTokens() );780 $this->assert Equals( 0.8, $config->getTemperature() );781 $this->assert Equals( 0.95, $config->getTopP() );782 $this->assert Equals( 50, $config->getTopK() );783 $this->assert Equals( 2, $config->getCandidateCount() );784 $this->assert Equals( 'application/json', $config->getOutputMimeType() );778 $this->assertSame( 'Be helpful', $config->getSystemInstruction() ); 779 $this->assertSame( 500, $config->getMaxTokens() ); 780 $this->assertSame( 0.8, $config->getTemperature() ); 781 $this->assertSame( 0.95, $config->getTopP() ); 782 $this->assertSame( 50, $config->getTopK() ); 783 $this->assertSame( 2, $config->getCandidateCount() ); 784 $this->assertSame( 'application/json', $config->getOutputMimeType() ); 785 785 } 786 786 … … 1002 1002 $merged_config = $this->get_wrapped_prompt_builder_property_value( $builder, 'modelConfig' ); 1003 1003 1004 $this->assert Equals( 'Builder instruction', $merged_config->getSystemInstruction() );1005 $this->assert Equals( 500, $merged_config->getMaxTokens() );1006 $this->assert Equals( 0.5, $merged_config->getTemperature() );1007 $this->assert Equals( 0.9, $merged_config->getTopP() );1008 $this->assert Equals( 40, $merged_config->getTopK() );1004 $this->assertSame( 'Builder instruction', $merged_config->getSystemInstruction() ); 1005 $this->assertSame( 500, $merged_config->getMaxTokens() ); 1006 $this->assertSame( 0.5, $merged_config->getTemperature() ); 1007 $this->assertSame( 0.9, $merged_config->getTopP() ); 1008 $this->assertSame( 40, $merged_config->getTopK() ); 1009 1009 } 1010 1010 … … 1029 1029 $this->assertArrayHasKey( 'stopSequences', $custom_options ); 1030 1030 $this->assertIsArray( $custom_options['stopSequences'] ); 1031 $this->assert Equals( array( 'CONFIG_STOP' ), $custom_options['stopSequences'] );1031 $this->assertSame( array( 'CONFIG_STOP' ), $custom_options['stopSequences'] ); 1032 1032 $this->assertArrayHasKey( 'otherOption', $custom_options ); 1033 $this->assert Equals( 'value', $custom_options['otherOption'] );1033 $this->assertSame( 'value', $custom_options['otherOption'] ); 1034 1034 1035 1035 $builder->using_stop_sequences( 'STOP' ); … … 1038 1038 $merged_config = $this->get_wrapped_prompt_builder_property_value( $builder, 'modelConfig' ); 1039 1039 1040 $this->assert Equals( array( 'STOP' ), $merged_config->getStopSequences() );1040 $this->assertSame( array( 'STOP' ), $merged_config->getStopSequences() ); 1041 1041 1042 1042 $custom_options = $merged_config->getCustomOptions(); 1043 1043 $this->assertArrayHasKey( 'stopSequences', $custom_options ); 1044 $this->assert Equals( array( 'CONFIG_STOP' ), $custom_options['stopSequences'] );1044 $this->assertSame( array( 'CONFIG_STOP' ), $custom_options['stopSequences'] ); 1045 1045 $this->assertArrayHasKey( 'otherOption', $custom_options ); 1046 $this->assert Equals( 'value', $custom_options['otherOption'] );1046 $this->assertSame( 'value', $custom_options['otherOption'] ); 1047 1047 } 1048 1048 … … 1059 1059 1060 1060 $actual_provider = $this->get_wrapped_prompt_builder_property_value( $builder, 'providerIdOrClassName' ); 1061 $this->assert Equals( 'test-provider', $actual_provider );1061 $this->assertSame( 'test-provider', $actual_provider ); 1062 1062 } 1063 1063 … … 1076 1076 $config = $this->get_wrapped_prompt_builder_property_value( $builder, 'modelConfig' ); 1077 1077 1078 $this->assert Equals( 'You are a helpful assistant.', $config->getSystemInstruction() );1078 $this->assertSame( 'You are a helpful assistant.', $config->getSystemInstruction() ); 1079 1079 } 1080 1080 … … 1093 1093 $config = $this->get_wrapped_prompt_builder_property_value( $builder, 'modelConfig' ); 1094 1094 1095 $this->assert Equals( 1000, $config->getMaxTokens() );1095 $this->assertSame( 1000, $config->getMaxTokens() ); 1096 1096 } 1097 1097 … … 1110 1110 $config = $this->get_wrapped_prompt_builder_property_value( $builder, 'modelConfig' ); 1111 1111 1112 $this->assert Equals( 0.7, $config->getTemperature() );1112 $this->assertSame( 0.7, $config->getTemperature() ); 1113 1113 } 1114 1114 … … 1127 1127 $config = $this->get_wrapped_prompt_builder_property_value( $builder, 'modelConfig' ); 1128 1128 1129 $this->assert Equals( 0.9, $config->getTopP() );1129 $this->assertSame( 0.9, $config->getTopP() ); 1130 1130 } 1131 1131 … … 1144 1144 $config = $this->get_wrapped_prompt_builder_property_value( $builder, 'modelConfig' ); 1145 1145 1146 $this->assert Equals( 40, $config->getTopK() );1146 $this->assertSame( 40, $config->getTopK() ); 1147 1147 } 1148 1148 … … 1161 1161 $config = $this->get_wrapped_prompt_builder_property_value( $builder, 'modelConfig' ); 1162 1162 1163 $this->assert Equals( array( 'STOP', 'END', '###' ), $config->getStopSequences() );1163 $this->assertSame( array( 'STOP', 'END', '###' ), $config->getStopSequences() ); 1164 1164 } 1165 1165 … … 1178 1178 $config = $this->get_wrapped_prompt_builder_property_value( $builder, 'modelConfig' ); 1179 1179 1180 $this->assert Equals( 3, $config->getCandidateCount() );1180 $this->assertSame( 3, $config->getCandidateCount() ); 1181 1181 } 1182 1182 … … 1195 1195 $config = $this->get_wrapped_prompt_builder_property_value( $builder, 'modelConfig' ); 1196 1196 1197 $this->assert Equals( 'application/json', $config->getOutputMimeType() );1197 $this->assertSame( 'application/json', $config->getOutputMimeType() ); 1198 1198 } 1199 1199 … … 1219 1219 $config = $this->get_wrapped_prompt_builder_property_value( $builder, 'modelConfig' ); 1220 1220 1221 $this->assert Equals( $schema, $config->getOutputSchema() );1221 $this->assertSame( $schema, $config->getOutputSchema() ); 1222 1222 } 1223 1223 … … 1259 1259 $config = $this->get_wrapped_prompt_builder_property_value( $builder, 'modelConfig' ); 1260 1260 1261 $this->assert Equals( 'application/json', $config->getOutputMimeType() );1261 $this->assertSame( 'application/json', $config->getOutputMimeType() ); 1262 1262 } 1263 1263 … … 1277 1277 $config = $this->get_wrapped_prompt_builder_property_value( $builder, 'modelConfig' ); 1278 1278 1279 $this->assert Equals( 'application/json', $config->getOutputMimeType() );1280 $this->assert Equals( $schema, $config->getOutputSchema() );1279 $this->assertSame( 'application/json', $config->getOutputMimeType() ); 1280 $this->assertSame( $schema, $config->getOutputSchema() ); 1281 1281 } 1282 1282 … … 1825 1825 1826 1826 $this->assertCount( 3, $texts ); 1827 $this->assert Equals( 'Text 1', $texts[0] );1828 $this->assert Equals( 'Text 2', $texts[1] );1829 $this->assert Equals( 'Text 3', $texts[2] );1827 $this->assertSame( 'Text 1', $texts[0] ); 1828 $this->assertSame( 'Text 2', $texts[1] ); 1829 $this->assertSame( 'Text 3', $texts[2] ); 1830 1830 1831 1831 /** @var ModelConfig $config */ 1832 1832 $config = $this->get_wrapped_prompt_builder_property_value( $builder, 'modelConfig' ); 1833 1833 1834 $this->assert Equals( 3, $config->getCandidateCount() );1834 $this->assertSame( 3, $config->getCandidateCount() ); 1835 1835 } 1836 1836 … … 2256 2256 $config = $this->get_wrapped_prompt_builder_property_value( $builder, 'modelConfig' ); 2257 2257 2258 $this->assert Equals( '16:9', $config->getOutputMediaAspectRatio() );2258 $this->assertSame( '16:9', $config->getOutputMediaAspectRatio() ); 2259 2259 } 2260 2260 … … 2273 2273 $config = $this->get_wrapped_prompt_builder_property_value( $builder, 'modelConfig' ); 2274 2274 2275 $this->assert Equals( 'alloy', $config->getOutputSpeechVoice() );2275 $this->assertSame( 'alloy', $config->getOutputSpeechVoice() ); 2276 2276 } 2277 2277 … … 2291 2291 $this->assertNotNull( $declarations ); 2292 2292 $this->assertCount( 1, $declarations ); 2293 $this->assert Equals( 'wpab__wpaiclienttests__simple', $declarations[0]->getName() );2294 $this->assert Equals( 'A simple test ability with no parameters.', $declarations[0]->getDescription() );2293 $this->assertSame( 'wpab__wpaiclienttests__simple', $declarations[0]->getName() ); 2294 $this->assertSame( 'A simple test ability with no parameters.', $declarations[0]->getDescription() ); 2295 2295 } 2296 2296 … … 2312 2312 $this->assertNotNull( $declarations ); 2313 2313 $this->assertCount( 1, $declarations ); 2314 $this->assert Equals( 'wpab__wpaiclienttests__with-params', $declarations[0]->getName() );2315 $this->assert Equals( 'A test ability that accepts parameters.', $declarations[0]->getDescription() );2314 $this->assertSame( 'wpab__wpaiclienttests__with-params', $declarations[0]->getName() ); 2315 $this->assertSame( 'A test ability that accepts parameters.', $declarations[0]->getDescription() ); 2316 2316 2317 2317 $params = $declarations[0]->getParameters(); … … 2340 2340 $this->assertNotNull( $declarations ); 2341 2341 $this->assertCount( 3, $declarations ); 2342 $this->assert Equals( 'wpab__wpaiclienttests__simple', $declarations[0]->getName() );2343 $this->assert Equals( 'wpab__wpaiclienttests__with-params', $declarations[1]->getName() );2344 $this->assert Equals( 'wpab__wpaiclienttests__returns-error', $declarations[2]->getName() );2342 $this->assertSame( 'wpab__wpaiclienttests__simple', $declarations[0]->getName() ); 2343 $this->assertSame( 'wpab__wpaiclienttests__with-params', $declarations[1]->getName() ); 2344 $this->assertSame( 'wpab__wpaiclienttests__returns-error', $declarations[2]->getName() ); 2345 2345 } 2346 2346 … … 2368 2368 $this->assertNotNull( $declarations ); 2369 2369 $this->assertCount( 2, $declarations ); 2370 $this->assert Equals( 'wpab__wpaiclienttests__simple', $declarations[0]->getName() );2371 $this->assert Equals( 'wpab__wpaiclienttests__with-params', $declarations[1]->getName() );2370 $this->assertSame( 'wpab__wpaiclienttests__simple', $declarations[0]->getName() ); 2371 $this->assertSame( 'wpab__wpaiclienttests__with-params', $declarations[1]->getName() ); 2372 2372 } 2373 2373 … … 2408 2408 $this->assertNotNull( $declarations ); 2409 2409 $this->assertCount( 2, $declarations ); 2410 $this->assert Equals( 'wpab__wpaiclienttests__simple', $declarations[0]->getName() );2411 $this->assert Equals( 'wpab__wpaiclienttests__with-params', $declarations[1]->getName() );2410 $this->assertSame( 'wpab__wpaiclienttests__simple', $declarations[0]->getName() ); 2411 $this->assertSame( 'wpab__wpaiclienttests__with-params', $declarations[1]->getName() ); 2412 2412 } 2413 2413 … … 2427 2427 $this->assertNotNull( $declarations ); 2428 2428 $this->assertCount( 1, $declarations ); 2429 $this->assert Equals( 'wpab__wpaiclienttests__hyphen-test', $declarations[0]->getName() );2429 $this->assertSame( 'wpab__wpaiclienttests__hyphen-test', $declarations[0]->getName() ); 2430 2430 } 2431 2431 … … 2449 2449 $this->assertNotNull( $declarations ); 2450 2450 $this->assertCount( 1, $declarations ); 2451 $this->assert Equals( 'wpab__wpaiclienttests__simple', $declarations[0]->getName() );2451 $this->assertSame( 'wpab__wpaiclienttests__simple', $declarations[0]->getName() ); 2452 2452 2453 2453 /** @var ModelConfig $config */ 2454 2454 $config = $this->get_wrapped_prompt_builder_property_value( $builder, 'modelConfig' ); 2455 2455 2456 $this->assert Equals( 'You are a helpful assistant', $config->getSystemInstruction() );2457 $this->assert Equals( 500, $config->getMaxTokens() );2456 $this->assertSame( 'You are a helpful assistant', $config->getSystemInstruction() ); 2457 $this->assertSame( 500, $config->getMaxTokens() ); 2458 2458 } 2459 2459
Note: See TracChangeset
for help on using the changeset viewer.