This repository was archived by the owner on Apr 30, 2019. It is now read-only.
File tree Expand file tree Collapse file tree
Fixtures/Integration/Symfony Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3232 "require-dev" : {
3333 "friendsofphp/php-cs-fixer" : " 2.x@dev" ,
3434 "phpunit/phpunit" : " ^5.6" ,
35- "symfony/phpunit-bridge" : " ^2.8|^3.1"
35+ "symfony/browser-kit" : " ^2.8|^3.1" ,
36+ "symfony/css-selector" : " ^2.8|^3.1" ,
37+ "symfony/dom-crawler" : " ^2.8|^3.1" ,
38+ "symfony/filesystem" : " ^2.8|^3.1" ,
39+ "symfony/framework-bundle" : " ^2.8|^3.1" ,
40+ "symfony/http-foundation" : " ^2.8|^3.1" ,
41+ "symfony/phpunit-bridge" : " ^2.8|^3.1" ,
42+ "symfony/twig-bundle" : " ^2.8|^3.1" ,
43+ "symfony/validator" : " ^2.8|^3.1" ,
44+ "symfony/var-dumper" : " ^2.8.11|^3.1"
3645 },
3746 "extra" : {
3847 "branch-alias" : {
Original file line number Diff line number Diff line change 99 processIsolation =" false"
1010 stopOnFailure =" false"
1111 syntaxCheck =" false"
12+ bootstrap =" tests/Fixtures/Integration/Symfony/app/bootstrap.php"
1213>
14+ <php >
15+ <server name =" KERNEL_DIR" value =" tests/Fixtures/Integration/Symfony/app/" />
16+ </php >
1317 <testsuites >
1418 <testsuite name =" Elao Symfony Form Simple Object Mapper Test Suite" >
1519 <directory >./tests/</directory >
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the "elao/form-simple-object-mapper" package.
5+ *
6+ * Copyright (C) 2016 Elao
7+ *
8+ * @author Elao <contact@elao.com>
9+ */
10+
11+ namespace Elao \FormSimpleObjectMapper \Tests \Fixtures \Integration \Symfony \Acme \Command ;
12+
13+ class AddItemToCartCommand
14+ {
15+ /** @var string */
16+ private $ reference ;
17+
18+ /** @var int */
19+ private $ quantity ;
20+
21+ public function __construct ($ reference , $ quantity )
22+ {
23+ $ this ->reference = $ reference ;
24+ $ this ->quantity = $ quantity ;
25+ }
26+
27+ /**
28+ * @return string
29+ */
30+ public function getReference ()
31+ {
32+ return $ this ->reference ;
33+ }
34+
35+ /**
36+ * @return int
37+ */
38+ public function getQuantity ()
39+ {
40+ return $ this ->quantity ;
41+ }
42+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the "elao/form-simple-object-mapper" package.
5+ *
6+ * Copyright (C) 2016 Elao
7+ *
8+ * @author Elao <contact@elao.com>
9+ */
10+
11+ namespace Elao \FormSimpleObjectMapper \Tests \Fixtures \Integration \Symfony \TestBundle \Controller ;
12+
13+ use Elao \FormSimpleObjectMapper \Tests \Fixtures \Integration \Symfony \TestBundle \Form \Type \AddItemToCartType ;
14+ use Symfony \Bundle \FrameworkBundle \Controller \Controller ;
15+ use Symfony \Component \HttpFoundation \Request ;
16+ use Symfony \Component \HttpFoundation \Response ;
17+ use Symfony \Component \VarDumper \Test \VarDumperTestTrait ;
18+
19+ class CartController extends Controller
20+ {
21+ use VarDumperTestTrait;
22+
23+ public function addItemAction (Request $ request )
24+ {
25+ $ form = $ this ->createForm (AddItemToCartType::class);
26+
27+ $ form ->handleRequest ($ request );
28+
29+ if ($ form ->isSubmitted () && $ form ->isValid ()) {
30+ $ command = $ form ->getData ();
31+
32+ return Response::create ($ this ->getDump ($ command ));
33+ }
34+
35+ return $ this ->render ('TestBundle:cart:add_item_to_cart.html.twig ' , [
36+ 'form ' => $ form ->createView (),
37+ ]);
38+ }
39+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the "elao/form-simple-object-mapper" package.
5+ *
6+ * Copyright (C) 2016 Elao
7+ *
8+ * @author Elao <contact@elao.com>
9+ */
10+
11+ namespace Elao \FormSimpleObjectMapper \Tests \Fixtures \Integration \Symfony \TestBundle \Form \Type ;
12+
13+ use Elao \FormSimpleObjectMapper \DataMapper \FormDataToObjectConverterInterface ;
14+ use Elao \FormSimpleObjectMapper \Tests \Fixtures \Integration \Symfony \Acme \Command \AddItemToCartCommand ;
15+ use Symfony \Component \Form \AbstractType ;
16+ use Symfony \Component \Form \Extension \Core \Type \HiddenType ;
17+ use Symfony \Component \Form \Extension \Core \Type \IntegerType ;
18+ use Symfony \Component \Form \FormBuilderInterface ;
19+ use Symfony \Component \OptionsResolver \OptionsResolver ;
20+
21+ class AddItemToCartType extends AbstractType implements FormDataToObjectConverterInterface
22+ {
23+ public function buildForm (FormBuilderInterface $ builder , array $ options )
24+ {
25+ $ builder
26+ ->add ('reference ' , HiddenType::class)
27+ ->add ('quantity ' , IntegerType::class)
28+ ;
29+ }
30+
31+ public function configureOptions (OptionsResolver $ resolver )
32+ {
33+ $ resolver ->setDefaults ([
34+ 'data_class ' => AddItemToCartCommand::class,
35+ 'simple_object_mapper ' => $ this ,
36+ ]);
37+ }
38+
39+ /**
40+ * {@inheritdoc}
41+ */
42+ public function convertFormDataToObject (array $ data , $ originalData )
43+ {
44+ return new AddItemToCartCommand (
45+ $ data ['reference ' ],
46+ $ data ['quantity ' ]
47+ );
48+ }
49+ }
Original file line number Diff line number Diff line change 1+ {{ form(form ) }}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the "elao/form-simple-object-mapper" package.
5+ *
6+ * Copyright (C) 2016 Elao
7+ *
8+ * @author Elao <contact@elao.com>
9+ */
10+
11+ namespace Elao \FormSimpleObjectMapper \Tests \Fixtures \Integration \Symfony \TestBundle ;
12+
13+ use Symfony \Component \HttpKernel \Bundle \Bundle ;
14+
15+ class TestBundle extends Bundle
16+ {
17+ }
Original file line number Diff line number Diff line change 1+ /cache /*
2+ /logs /*
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the "elao/form-simple-object-mapper" package.
5+ *
6+ * Copyright (C) 2016 Elao
7+ *
8+ * @author Elao <contact@elao.com>
9+ */
10+
11+ use Elao \FormSimpleObjectMapper \Tests \Fixtures \Integration \Symfony \TestBundle \TestBundle ;
12+ use Symfony \Bundle \FrameworkBundle \FrameworkBundle ;
13+ use Symfony \Bundle \TwigBundle \TwigBundle ;
14+ use Symfony \Component \Config \Loader \LoaderInterface ;
15+ use Symfony \Component \HttpKernel \Kernel ;
16+
17+ /**
18+ * AppKernel for tests.
19+ */
20+ class AppKernel extends Kernel
21+ {
22+ public function registerBundles ()
23+ {
24+ return [
25+ new FrameworkBundle (),
26+ new TwigBundle (),
27+ new TestBundle (),
28+ ];
29+ }
30+
31+ public function registerContainerConfiguration (LoaderInterface $ loader )
32+ {
33+ $ loader ->load ($ this ->getRootDir () . '/config/config.yml ' );
34+ }
35+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the "elao/form-simple-object-mapper" package.
5+ *
6+ * Copyright (C) 2016 Elao
7+ *
8+ * @author Elao <contact@elao.com>
9+ */
10+
11+ use Symfony \Component \Filesystem \Filesystem ;
12+
13+ date_default_timezone_set ('UTC ' );
14+
15+ $ loader = require __DIR__ . '/../../../../../vendor/autoload.php ' ;
16+
17+ require __DIR__ . '/AppKernel.php ' ;
18+
19+ // Empty generated symfony cache
20+ (new Filesystem ())->remove (__DIR__ . '/cache ' );
21+
22+ return $ loader ;
You can’t perform that action at this time.
0 commit comments