feat: all-season assignments
This commit is contained in:
1 parent
675cec1b69
commit
cf876ed224
119 files changed
+6194
-294
No files matched your search
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Form;
|
||||
|
||||
use App\Form\AutosizeTextareaType;
|
||||
use Symfony\Component\Form\Test\TypeTestCase;
|
||||
|
||||
/**
|
||||
* The Stimulus wiring is what this type exists for, so it is asserted here rather than
|
||||
* repeated in every form type that uses it.
|
||||
*
|
||||
* The rows attribute is deliberately not part of it: textarea_autosize_controller.js
|
||||
* overwrites rows on connect, which is why the floor travels as min_rows instead.
|
||||
*/
|
||||
class AutosizeTextareaTypeTest extends TypeTestCase
|
||||
{
|
||||
public function testTheControllerAndItsResizeActionAreWiredUp(): void
|
||||
{
|
||||
$attr = $this->attr();
|
||||
|
||||
$this->assertSame('textarea-autosize', $attr['data-controller']);
|
||||
$this->assertSame('textarea-autosize#resize', $attr['data-action']);
|
||||
}
|
||||
|
||||
/**
|
||||
* One row is what the controller itself defaults to, so a field that says nothing
|
||||
* renders exactly as it did before this type existed.
|
||||
*/
|
||||
public function testTheFloorDefaultsToASingleRow(): void
|
||||
{
|
||||
$this->assertSame(1, $this->attr()['data-textarea-autosize-min-rows-value']);
|
||||
}
|
||||
|
||||
public function testMinRowsReachesTheController(): void
|
||||
{
|
||||
$this->assertSame(12, $this->attr(['min_rows' => 12])['data-textarea-autosize-min-rows-value']);
|
||||
}
|
||||
|
||||
/**
|
||||
* A field needing a second Stimulus controller on the same element has to compose the
|
||||
* list itself, so its own attributes must win over the defaults.
|
||||
*/
|
||||
public function testTheCallersOwnAttributesWin(): void
|
||||
{
|
||||
$attr = $this->attr(['attr' => ['data-controller' => 'textarea-autosize other', 'placeholder' => 'x']]);
|
||||
|
||||
$this->assertSame('textarea-autosize other', $attr['data-controller']);
|
||||
$this->assertSame('x', $attr['placeholder']);
|
||||
$this->assertSame('textarea-autosize#resize', $attr['data-action']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function attr(array $options = []): array
|
||||
{
|
||||
return $this->factory->create(AutosizeTextareaType::class, null, $options)->createView()->vars['attr'];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user