Skip to content

Commit

Permalink
minor #1069 Fixing various tests and deprecations (weaverryan)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 2.x branch.

Discussion
----------

Fixing various tests and deprecations

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| Tickets       | None
| License       | MIT

Hi!

This fixes various deprecations and some tests due to upstream changes.

Cheers!

Commits
-------

78f05d0 Fixing various tests and deprecations
  • Loading branch information
weaverryan committed Aug 24, 2023
2 parents 02d661b + 78f05d0 commit ef7ddb2
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 38 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test-turbo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,5 @@ jobs:
- name: Run tests
working-directory: src/Turbo
run: vendor/bin/simple-phpunit
env:
SYMFONY_DEPRECATIONS_HELPER: 'max[self]=1'
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
16 changes: 15 additions & 1 deletion src/Cropperjs/tests/Kernel/FrameworkAppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,21 @@ public function registerBundles(): iterable
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(function (ContainerBuilder $container) {
$container->loadFromExtension('framework', ['secret' => '$ecret', 'test' => true]);
$frameworkConfig = [
'secret' => '$ecret',
'test' => true,
'http_method_override' => false,
'php_errors' => ['log' => true],
'validation' => [
'email_validation_mode' => 'html5',
],
];

if (self::VERSION_ID >= 60200) {
$frameworkConfig['handle_all_throwables'] = true;
}

$container->loadFromExtension('framework', $frameworkConfig);
});
}
}
16 changes: 15 additions & 1 deletion src/Cropperjs/tests/Kernel/TwigAppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,21 @@ 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]);
$frameworkConfig = [
'secret' => '$ecret',
'test' => true,
'http_method_override' => false,
'php_errors' => ['log' => true],
'validation' => [
'email_validation_mode' => 'html5',
],
];

if (self::VERSION_ID >= 60200) {
$frameworkConfig['handle_all_throwables'] = true;
}

$container->loadFromExtension('framework', $frameworkConfig);
$container->loadFromExtension('twig', ['default_path' => __DIR__.'/templates', 'strict_variables' => true, 'exception_controller' => null]);

// create a public alias - FormFactoryInterface is removed otherwise
Expand Down
3 changes: 3 additions & 0 deletions src/LiveComponent/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
## 2.11.0

- Add helper for testing live components.
- Add initial file upload support.
- Respect `data-turbo="false"` when handling redirects.
- Fix checksum calculation for deeply nested data.

## 2.9.0

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
5 changes: 5 additions & 0 deletions src/TogglePassword/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CHANGELOG

## 2.11.0

- Introduce component!
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
15 changes: 14 additions & 1 deletion src/TogglePassword/tests/Kernel/TwigAppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,20 @@ 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]);
$frameworkConfig = [
'secret' => '$ecret',
'test' => true,
'http_method_override' => false,
'php_errors' => [
'log' => true,
],
];

if (self::VERSION_ID >= 60200) {
$frameworkConfig['handle_all_throwables'] = true;
}

$container->loadFromExtension('framework', $frameworkConfig);
$container->loadFromExtension('twig', [
'default_path' => __DIR__.'/templates',
'strict_variables' => true,
Expand Down
2 changes: 1 addition & 1 deletion src/Turbo/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"symfony/stimulus-bundle": "^2.9.1"
},
"require-dev": {
"doctrine/annotations": "^1.12",
"doctrine/doctrine-bundle": "^2.4.3",
"doctrine/orm": "^2.8 | 3.0",
"phpstan/phpstan": "^1.10",
Expand All @@ -49,6 +48,7 @@
"symfony/messenger": "^5.4|^6.0",
"symfony/panther": "^1.0|^2.0",
"symfony/phpunit-bridge": "^5.4|^6.0",
"symfony/process": "^5.4|6.3.*",
"symfony/property-access": "^5.4|^6.0",
"symfony/security-core": "^5.4|^6.0",
"symfony/stopwatch": "^5.4|^6.0",
Expand Down
15 changes: 15 additions & 0 deletions src/Turbo/phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,18 @@ parameters:
inferPrivatePropertyTypeFromConstructor: true
bootstrapFiles:
- vendor/bin/.phpunit/phpunit/vendor/autoload.php
ignoreErrors:
-
message: "#^Call to method getClassAnnotations\\(\\) on an unknown class Doctrine\\\\Common\\\\Annotations\\\\Reader\\.$#"
count: 1
path: src/Doctrine/BroadcastListener.php

-
message: "#^Parameter \\$annotationReader of method Symfony\\\\UX\\\\Turbo\\\\Doctrine\\\\BroadcastListener\\:\\:__construct\\(\\) has invalid type Doctrine\\\\Common\\\\Annotations\\\\Reader\\.$#"
count: 1
path: src/Doctrine/BroadcastListener.php

-
message: "#^Property Symfony\\\\UX\\\\Turbo\\\\Doctrine\\\\BroadcastListener\\:\\:\\$annotationReader has unknown class Doctrine\\\\Common\\\\Annotations\\\\Reader as its type\\.$#"
count: 1
path: src/Doctrine/BroadcastListener.php
3 changes: 3 additions & 0 deletions src/TwigComponent/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
## 2.11.0

- Support ...spread operator with html syntax (requires Twig 3.7.0 or higher)
- Add support for anonymous Twig components.
- Add `RenderedComponent::crawler()` and `toString()` methods.
- Allow a block outside a Twig component to be available inside via `outerBlocks`.
- Fix `<twig:component>` syntax where an attribute is set to an empty value.

## 2.9.0

Expand Down

0 comments on commit ef7ddb2

Please sign in to comment.