ContextFactoryTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  5. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  6. *
  7. * Licensed under The MIT License
  8. * For full copyright and license information, please see the LICENSE.txt
  9. * Redistributions of files must retain the above copyright notice.
  10. *
  11. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  12. * @link https://cakephp.org CakePHP(tm) Project
  13. * @since 4.0.0
  14. * @license https://opensource.org/licenses/mit-license.php MIT License
  15. */
  16. namespace Cake\Test\TestCase\View\Form;
  17. use Cake\Core\Exception\CakeException;
  18. use Cake\Http\ServerRequest;
  19. use Cake\TestSuite\TestCase;
  20. use Cake\View\Form\ContextFactory;
  21. /**
  22. * ContextFactory test case.
  23. */
  24. class ContextFactoryTest extends TestCase
  25. {
  26. public function testGetException(): void
  27. {
  28. $this->expectException(CakeException::class);
  29. $this->expectExceptionMessage(
  30. 'No context provider found for value of type `bool`.'
  31. . ' Use `null` as 1st argument of FormHelper::create() to create a context-less form.'
  32. );
  33. $factory = new ContextFactory();
  34. $factory->get(new ServerRequest(), ['entity' => false]);
  35. }
  36. }