Repository navigation
v2.12.4
Note
No behavior changes. This release adds the IntegrationTestTrait / EmailTrait backport for request-level controller tests (see UPGRADE.md) and fixes docblock types and flaky tests.
Integration Testing Backport (PR #51)
- IntegrationTestTrait: New test trait, a backport of
Cake\TestSuite\IntegrationTestTraitfrom CakePHP 5.x (src/TestSuite/IntegrationTestTrait.php) adapted to CakePHP 2. Dispatches requests through the realDispatcherand captures theCakeResponse; usable from any test case (noControllerTestCaseneeded)- Requests:
get(),post(),put(),patch(),delete(),head(),options()with string URLs, full URLs or routing arrays, array data or a raw body - Setup:
configRequest(),replaceRequest(),requestAsJson(),session(),cookie(),cookieEncrypted()(CookieComponentformat),enableSecurityToken()/setUnlockedFields()(validSecurityComponent_Tokenfields and CSRF token),enableCsrfToken(),enableRetainFlashMessages(),disableErrorHandlerMiddleware()(throw exceptions instead of rendering the error page) - Assertions on the status, redirect, headers, content type, body, template, layout, session, flash messages, cookies and sent files (
assertResponseOk(),assertRedirect(),assertHeader(),assertResponseContains(),assertTemplate(),assertSession(),assertFlashMessage(),assertCookieEncrypted(),assertFileResponse(), ...), andviewVariable() exitafter a sent response (Controller::redirect(),AuthComponent,AssetDispatcher, redirect routes) is replaced byIntegrationTestStop, thrown by the test responseIntegrationTestResponse;IntegrationTestDispatcherdispatches without sending the response
- Requests:
- Constraints: PHPUnit constraints backported from src/TestSuite/Constraint (
Response/*,Session/*,View/*,Email/*), named with aConstraintsuffix (e.g.StatusOkConstraint,FlashParamEqualsConstraint,MailSentToConstraint) - EmailTrait / TestEmailTransport: Backport of src/TestSuite/EmailTrait.php and src/TestSuite/TestEmailTransport.php. Every
CakeEmailsends withTestEmailTransportduring the test, andassertMailCount(),assertNoMailSent(),assertMailSentTo(),assertMailSentFrom(),assertMailSentWith(),assertMailContains(),assertMailContainsText(),assertMailContainsHtml(),assertMailSubjectContains(),assertMailContainsAttachment()(and...At()variants) check the captured emails - CakeEmail: New
CakeEmail::overrideTransport($name)/CakeEmail::transportOverride()to make every instance use one transport (used byTestEmailTransport::replaceAllTransports()); no change unless called - CookieCryptTrait (TestSuite): Encrypts and decrypts values in the
CookieComponentformat, backport ofCake\Utility\CookieCryptTrait
Docblock Types (PR #49)
- ErrorHandler / ExceptionRenderer: Document the
$exceptionparameters ofhandleException(),_getMessage(),_log(),ExceptionRenderer::__construct()and_getController()asThrowable, matching whatset_exception_handler()passes on PHP 8 (no behavior change) - View: Document
$subDirasstring|null(its default isnull) - AclComponent: Document
$Aro/$Acoas the ACL adapter's node objects (Aro|PhpAro|null/Aco|PhpAco|null) instead ofstring - Tests: Fix flaky
testConfigurationConflictinMemcacheEngineTest/MemcachedEngineTest(one-second expiry granularity), andCakeTimeTest::testWasWithinLast/testTimeAgoInWords(the clock can tick between the relative input and "now")