-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
205 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ jobs: | |
--tmpfs /var/tmp:exec | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v1 | ||
uses: actions/checkout@v2 | ||
- name: Install Composer | ||
run: wget -qO - https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet | ||
- name: Cache Composer dependencies | ||
|
@@ -32,8 +32,12 @@ jobs: | |
composer- | ||
- name: Validate Composer | ||
run: composer validate | ||
- name: Install xsl PHP extension | ||
run: | | ||
apk add $PHPIZE_DEPS libxslt-dev | ||
docker-php-ext-install xsl | ||
- name: Install highest dependencies with Composer | ||
run: composer update --no-progress --no-suggest --ignore-platform-reqs --ansi | ||
run: composer update --no-progress --no-suggest --ansi | ||
- name: Disable PHP memory limit | ||
run: echo 'memory_limit=-1' >> /usr/local/etc/php/php.ini | ||
- name: Analyze | ||
|
@@ -59,7 +63,7 @@ jobs: | |
fail-fast: false | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v1 | ||
uses: actions/checkout@v2 | ||
- name: Install Composer | ||
run: wget -qO - https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet | ||
- name: Cache Composer dependencies | ||
|
@@ -70,12 +74,16 @@ jobs: | |
restore-keys: | | ||
composer-php${{ matrix.php }}-${{ matrix.dependencies }}- | ||
composer- | ||
- name: Install xsl PHP extension | ||
run: | | ||
apk add $PHPIZE_DEPS libxslt-dev | ||
docker-php-ext-install xsl | ||
- name: Install lowest dependencies with Composer | ||
if: matrix.dependencies == 'lowest' | ||
run: composer update --no-progress --no-suggest --prefer-stable --prefer-lowest --ignore-platform-reqs --ansi | ||
run: composer update --no-progress --no-suggest --prefer-stable --prefer-lowest --ansi | ||
- name: Install highest dependencies with Composer | ||
if: matrix.dependencies == 'highest' | ||
run: composer update --no-progress --no-suggest --ignore-platform-reqs --ansi | ||
run: composer update --no-progress --no-suggest --ansi | ||
- name: Run tests with PHPUnit | ||
run: vendor/bin/simple-phpunit --colors=always | ||
|
||
|
@@ -93,7 +101,7 @@ jobs: | |
- '7.4' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v1 | ||
uses: actions/checkout@v2 | ||
- name: Install pcov PHP extension | ||
run: | | ||
apk add $PHPIZE_DEPS | ||
|
@@ -109,11 +117,15 @@ jobs: | |
restore-keys: | | ||
composer-php${{ matrix.php }}-highest- | ||
composer- | ||
- name: Install xsl PHP extension | ||
run: | | ||
apk add $PHPIZE_DEPS libxslt-dev | ||
docker-php-ext-install xsl | ||
- name: Install highest dependencies with Composer | ||
run: composer update --no-progress --no-suggest --ignore-platform-reqs --ansi | ||
run: composer update --no-progress --no-suggest --ansi | ||
- name: Run coverage with PHPUnit | ||
run: vendor/bin/simple-phpunit --coverage-clover ./coverage.xml --colors=always | ||
- name: Send code coverage report to Codecov.io | ||
uses: codecov/[email protected] | ||
uses: codecov/[email protected] # 1.0.4+ uncompatible alpine :/ | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the AutoFormBundle package. | ||
* | ||
* (c) David ALLIX <http://a2lix.fr> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace A2lix\AutoFormBundle\Tests\Form\Type; | ||
|
||
use A2lix\AutoFormBundle\Form\Type\AutoFormType; | ||
use A2lix\AutoFormBundle\Tests\Fixtures\Entity\Media; | ||
use A2lix\AutoFormBundle\Tests\Fixtures\Entity\Product; | ||
use A2lix\AutoFormBundle\Tests\Form\TypeTestCase; | ||
use Symfony\Component\Form\Extension\Core\Type\SubmitType; | ||
use Symfony\Component\Form\PreloadedExtension; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class AutoFormTypeAdvancedTest extends TypeTestCase | ||
{ | ||
public function testCreationFormWithOverriddenFieldsLabel(): Product | ||
{ | ||
$form = $this->factory->createBuilder(AutoFormType::class, new Product(), [ | ||
'fields' => [ | ||
'url' => [ | ||
'label' => 'URL/URI', | ||
], | ||
], | ||
]) | ||
->add('create', SubmitType::class) | ||
->getForm() | ||
; | ||
|
||
$media1 = new Media(); | ||
$media1->setUrl('http://example.org/media1') | ||
->setDescription('media1 desc') | ||
; | ||
$media2 = new Media(); | ||
$media2->setUrl('http://example.org/media2') | ||
->setDescription('media2 desc') | ||
; | ||
|
||
$product = new Product(); | ||
$product->setUrl('a2lix.fr') | ||
->addMedia($media1) | ||
->addMedia($media2) | ||
; | ||
|
||
$formData = [ | ||
'url' => 'a2lix.fr', | ||
'medias' => [ | ||
[ | ||
'url' => 'http://example.org/media1', | ||
'description' => 'media1 desc', | ||
], | ||
[ | ||
'url' => 'http://example.org/media2', | ||
'description' => 'media2 desc', | ||
], | ||
], | ||
]; | ||
|
||
$form->submit($formData); | ||
static::assertTrue($form->isSynchronized()); | ||
static::assertEquals($product, $form->getData()); | ||
static::assertEquals('URL/URI', $form->get('url')->getConfig()->getOptions()['label']); | ||
|
||
return $product; | ||
} | ||
|
||
public function testCreationFormWithOverriddenFieldsMappedFalse(): Product | ||
{ | ||
$form = $this->factory->createBuilder(AutoFormType::class, new Product(), [ | ||
'fields' => [ | ||
'color' => [ | ||
'mapped' => false, | ||
], | ||
], | ||
]) | ||
->add('create', SubmitType::class) | ||
->getForm() | ||
; | ||
|
||
$media1 = new Media(); | ||
$media1->setUrl('http://example.org/media1') | ||
->setDescription('media1 desc') | ||
; | ||
$media2 = new Media(); | ||
$media2->setUrl('http://example.org/media2') | ||
->setDescription('media2 desc') | ||
; | ||
|
||
$product = new Product(); | ||
$product->setUrl('a2lix.fr') | ||
->addMedia($media1) | ||
->addMedia($media2) | ||
; | ||
|
||
$formData = [ | ||
'url' => 'a2lix.fr', | ||
'color' => 'blue', | ||
'medias' => [ | ||
[ | ||
'url' => 'http://example.org/media1', | ||
'description' => 'media1 desc', | ||
], | ||
[ | ||
'url' => 'http://example.org/media2', | ||
'description' => 'media2 desc', | ||
], | ||
], | ||
]; | ||
|
||
$form->submit($formData); | ||
static::assertTrue($form->isSynchronized()); | ||
static::assertEquals($product, $form->getData()); | ||
static::assertEquals('blue', $form->get('color')->getData()); | ||
|
||
return $product; | ||
} | ||
|
||
protected function getExtensions(): array | ||
{ | ||
$autoFormType = $this->getConfiguredAutoFormType(); | ||
|
||
return [new PreloadedExtension([ | ||
$autoFormType, | ||
], [])]; | ||
} | ||
} |