@@ -2722,6 +2722,104 @@ public function testColor()
27222722 [@name="name"]
27232723 [@class="my&class form-control"]
27242724 [@value="#0000ff"]
2725+ '
2726+ );
2727+ }
2728+
2729+ public function testWeekSingleText ()
2730+ {
2731+ $ this ->requiresFeatureSet (404 );
2732+
2733+ $ form = $ this ->factory ->createNamed ('holidays ' , 'Symfony\Component\Form\Extension\Core\Type\WeekType ' , '1970-W01 ' , [
2734+ 'input ' => 'string ' ,
2735+ 'widget ' => 'single_text ' ,
2736+ ]);
2737+
2738+ $ this ->assertWidgetMatchesXpath ($ form ->createView (), ['attr ' => ['class ' => 'my&class ' ]],
2739+ '/input
2740+ [@type="week"]
2741+ [@name="holidays"]
2742+ [@class="my&class form-control"]
2743+ [@value="1970-W01"]
2744+ [not(@maxlength)]
2745+ '
2746+ );
2747+ }
2748+
2749+ public function testWeekSingleTextNoHtml5 ()
2750+ {
2751+ $ this ->requiresFeatureSet (404 );
2752+
2753+ $ form = $ this ->factory ->createNamed ('holidays ' , 'Symfony\Component\Form\Extension\Core\Type\WeekType ' , '1970-W01 ' , [
2754+ 'input ' => 'string ' ,
2755+ 'widget ' => 'single_text ' ,
2756+ 'html5 ' => false ,
2757+ ]);
2758+
2759+ $ this ->assertWidgetMatchesXpath ($ form ->createView (), ['attr ' => ['class ' => 'my&class ' ]],
2760+ '/input
2761+ [@type="text"]
2762+ [@name="holidays"]
2763+ [@class="my&class form-control"]
2764+ [@value="1970-W01"]
2765+ [not(@maxlength)]
2766+ '
2767+ );
2768+ }
2769+
2770+ public function testWeekChoices ()
2771+ {
2772+ $ this ->requiresFeatureSet (404 );
2773+
2774+ $ data = ['year ' => date ('Y ' ), 'week ' => 1 ];
2775+
2776+ $ form = $ this ->factory ->createNamed ('name ' , 'Symfony\Component\Form\Extension\Core\Type\WeekType ' , $ data , [
2777+ 'input ' => 'array ' ,
2778+ 'required ' => false ,
2779+ ]);
2780+
2781+ $ this ->assertWidgetMatchesXpath ($ form ->createView (), ['attr ' => ['class ' => 'my&class ' ]],
2782+ '/div
2783+ [@class="my&class"]
2784+ [
2785+ ./select
2786+ [@id="name_year"]
2787+ [@class="form-control"]
2788+ [./option[@value=" ' .$ data ['year ' ].'"][@selected="selected"]]
2789+ /following-sibling::select
2790+ [@id="name_week"]
2791+ [@class="form-control"]
2792+ [./option[@value=" ' .$ data ['week ' ].'"][@selected="selected"]]
2793+ ]
2794+ [count(.//select)=2] '
2795+ );
2796+ }
2797+
2798+ public function testWeekText ()
2799+ {
2800+ $ this ->requiresFeatureSet (404 );
2801+
2802+ $ form = $ this ->factory ->createNamed ('name ' , 'Symfony\Component\Form\Extension\Core\Type\WeekType ' , '2000-W01 ' , [
2803+ 'input ' => 'string ' ,
2804+ 'widget ' => 'text ' ,
2805+ ]);
2806+
2807+ $ this ->assertWidgetMatchesXpath ($ form ->createView (), ['attr ' => ['class ' => 'my&class ' ]],
2808+ '/div
2809+ [@class="my&class"]
2810+ [
2811+ ./input
2812+ [@id="name_year"]
2813+ [@type="number"]
2814+ [@class="form-control"]
2815+ [@value="2000"]
2816+ /following-sibling::input
2817+ [@id="name_week"]
2818+ [@type="number"]
2819+ [@class="form-control"]
2820+ [@value="1"]
2821+ ]
2822+ [count(./input)=2]
27252823 '
27262824 );
27272825 }
0 commit comments