Skip to content

Commit

Permalink
Fixing various tests and deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverryan committed Aug 24, 2023
1 parent 02d661b commit ac930c9
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 37 deletions.
41 changes: 12 additions & 29 deletions src/Cropperjs/tests/Form/CropperTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,13 @@ public function testRenderFull()

$rendered = $container->get(Environment::class)->render('cropper_form.html.twig', ['form' => $form->createView()]);

$this->assertSame(
'<form name="form" method="post">'.
'<div id="form">'.
'<div>'.
'<div id="form_photo" class="cropperjs">'.
'<input type="hidden" id="form_photo_options" name="form[photo][options]" '.
'data-controller="mycropper symfony--ux-cropperjs--cropper" '.
'data-symfony--ux-cropperjs--cropper-public-url-value="/public/url.jpg" '.
'data-symfony--ux-cropperjs--cropper-options-value="{&quot;viewMode&quot;:1,&quot;dragMode&quot;:&quot;move&quot;}" />'.
'</div>'.
'</div>'.
'</div>'.
'</form>
',
str_replace(' >', '>', $rendered)
$this->assertStringContainsString('<div id="form_photo" class="cropperjs">', $rendered);
$this->assertStringContainsString(
'<input type="hidden" id="form_photo_options" name="form[photo][options]" '.
'data-controller="mycropper symfony--ux-cropperjs--cropper" '.
'data-symfony--ux-cropperjs--cropper-public-url-value="/public/url.jpg" '.
'data-symfony--ux-cropperjs--cropper-options-value="{&quot;viewMode&quot;:1,&quot;dragMode&quot;:&quot;move&quot;}"',
$rendered,
);
}

Expand All @@ -78,20 +70,11 @@ public function testRenderNoOptions()

$rendered = $container->get(Environment::class)->render('cropper_form.html.twig', ['form' => $form->createView()]);

$this->assertSame(
'<form name="form" method="post">'.
'<div id="form">'.
'<div>'.
'<div id="form_photo" class="cropperjs">'.
'<input type="hidden" id="form_photo_options" name="form[photo][options]" '.
'data-controller="mycropper symfony--ux-cropperjs--cropper" '.
'data-symfony--ux-cropperjs--cropper-public-url-value="/public/url.jpg" '.
'data-symfony--ux-cropperjs--cropper-options-value="[]" />'.
'</div>'.
'</div>'.
'</div>'.
'</form>
',
$this->assertStringContainsString(
'<input type="hidden" id="form_photo_options" name="form[photo][options]" '.
'data-controller="mycropper symfony--ux-cropperjs--cropper" '.
'data-symfony--ux-cropperjs--cropper-public-url-value="/public/url.jpg" '.
'data-symfony--ux-cropperjs--cropper-options-value="[]"',
str_replace(' >', '>', $rendered)
);
}
Expand Down
11 changes: 10 additions & 1 deletion src/Cropperjs/tests/Kernel/FrameworkAppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,16 @@ public function registerBundles(): iterable
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(function (ContainerBuilder $container) {
$container->loadFromExtension('framework', ['secret' => '$ecret', 'test' => true]);
$container->loadFromExtension('framework', [
'secret' => '$ecret',
'test' => true,
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'validation' => [
'email_validation_mode' => 'html5',
],
]);
});
}
}
11 changes: 10 additions & 1 deletion src/Cropperjs/tests/Kernel/TwigAppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ public function registerBundles(): iterable
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(function (ContainerBuilder $container) {
$container->loadFromExtension('framework', ['secret' => '$ecret', 'test' => true, 'http_method_override' => false]);
$container->loadFromExtension('framework', [
'secret' => '$ecret',
'test' => true,
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'validation' => [
'email_validation_mode' => 'html5',
],
]);
$container->loadFromExtension('twig', ['default_path' => __DIR__.'/templates', 'strict_variables' => true, 'exception_controller' => null]);

// create a public alias - FormFactoryInterface is removed otherwise
Expand Down
2 changes: 1 addition & 1 deletion src/StimulusBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"twig/twig": "^2.15.3|^3.4.3"
},
"require-dev": {
"symfony/asset-mapper": "6.3.x-dev",
"symfony/asset-mapper": "^6.3",
"symfony/framework-bundle": "^5.4|^6.0",
"symfony/phpunit-bridge": "^5.4|^6.0",
"symfony/twig-bundle": "^5.4|^6.0",
Expand Down
4 changes: 4 additions & 0 deletions src/StimulusBundle/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>

<extensions>
<extension class="Zenstruck\Browser\Test\BrowserExtension" />
</extensions>
</phpunit>
2 changes: 2 additions & 0 deletions src/StimulusBundle/tests/fixtures/StimulusTestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ protected function configureContainer(ContainerConfigurator $container): void
],
],
'test' => true,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
]);

$container->extension('twig', [
Expand Down
6 changes: 2 additions & 4 deletions src/TogglePassword/tests/Form/TogglePasswordTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public function testRenderFormWithToggle(): void

$rendered = $container->get(Environment::class)->render('toggle_password_form.html.twig', ['form' => $form->createView()]);

self::assertSame('<form name="form" method="post"><div id="form"><div><label for="form_password" class="required">Password</label><div class="toggle-password-container"><input type="password" id="form_password" name="form[password]" required="required" data-controller="symfony--ux-toggle-password--toggle-password" data-symfony--ux-toggle-password--toggle-password-hidden-label-value="Hide" data-symfony--ux-toggle-password--toggle-password-visible-label-value="Show" data-symfony--ux-toggle-password--toggle-password-hidden-icon-value="Default" data-symfony--ux-toggle-password--toggle-password-visible-icon-value="Default" data-symfony--ux-toggle-password--toggle-password-button-classes-value="[&quot;toggle-password-button&quot;]" /></div></div></div></form>
', $rendered);
self::assertStringContainsString('<div class="toggle-password-container"><input type="password" id="form_password" name="form[password]" required="required" data-controller="symfony--ux-toggle-password--toggle-password" data-symfony--ux-toggle-password--toggle-password-hidden-label-value="Hide" data-symfony--ux-toggle-password--toggle-password-visible-label-value="Show" data-symfony--ux-toggle-password--toggle-password-hidden-icon-value="Default" data-symfony--ux-toggle-password--toggle-password-visible-icon-value="Default" data-symfony--ux-toggle-password--toggle-password-button-classes-value="[&quot;toggle-password-button&quot;]"', $rendered);
}

public function testRenderFormWithoutToggle(): void
Expand All @@ -36,8 +35,7 @@ public function testRenderFormWithoutToggle(): void

$rendered = $container->get(Environment::class)->render('toggle_password_form.html.twig', ['form' => $form->createView()]);

self::assertSame('<form name="form" method="post"><div id="form"><div><label for="form_password" class="required">Password</label><input type="password" id="form_password" name="form[password]" required="required" /></div></div></form>
', $rendered);
self::assertStringContainsString('<input type="password" id="form_password" name="form[password]" required="required"', $rendered);
}

private function givenServiceContainer(): ?object
Expand Down
10 changes: 9 additions & 1 deletion src/TogglePassword/tests/Kernel/TwigAppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ public function registerBundles(): iterable
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(function (ContainerBuilder $container) {
$container->loadFromExtension('framework', ['secret' => '$ecret', 'test' => true, 'http_method_override' => false]);
$container->loadFromExtension('framework', [
'secret' => '$ecret',
'test' => true,
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => [
'log' => true,
],
]);
$container->loadFromExtension('twig', [
'default_path' => __DIR__.'/templates',
'strict_variables' => true,
Expand Down

0 comments on commit ac930c9

Please sign in to comment.