-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjust ImageForm logic to support new behaviour to be introduce in silverstripe/assets 1.6 #78
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -2,21 +2,32 @@ | |
|
||
language: php | ||
sudo: false | ||
dist: trusty | ||
dist: xenial | ||
|
||
services: | ||
- mysql | ||
- postgresql | ||
|
||
env: | ||
global: | ||
- COMPOSER_ROOT_VERSION=3.0.x-dev | ||
- COMPOSER_ROOT_VERSION=3.x-dev | ||
- SS_ENVIRONMENT_TYPE="dev" | ||
- DB=MYSQL | ||
|
||
matrix: | ||
include: | ||
- php: 5.6 | ||
env: | ||
- DB=MYSQL | ||
- ASSET_VERSION=1.4.x-dev | ||
- php: 7.1 | ||
env: | ||
- DB=PGSQL | ||
- php: 7.3 | ||
env: | ||
- ASSET_VERSION=1.5.x-dev | ||
- php: 7.4 | ||
env: | ||
- ASSET_VERSION=1.x-dev | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test against the new layout |
||
|
||
before_script: | ||
# Init PHP | ||
|
@@ -27,8 +38,11 @@ before_script: | |
# Install composer dependencies | ||
- export PATH=~/.composer/vendor/bin:$PATH | ||
- composer validate | ||
- composer install --prefer-source | ||
- if [[ $DB == PGSQL ]]; then composer require silverstripe/postgresql:^2.2 --prefer-source; fi | ||
- composer require silverstripe/assets $ASSET_VERSION --no-update | ||
- composer require silverstripe/asset-admin $ASSET_VERSION --no-update | ||
- if [[ $DB == PGSQL ]]; then composer require silverstripe/postgresql:^2.2 --no-update; fi | ||
- composer update --prefer-source | ||
|
||
|
||
script: | ||
- vendor/bin/phpunit |
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
91 changes: 91 additions & 0 deletions
91
tests/Extensions/FocusPointAssetFormFactoryExtensionTest.php
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,91 @@ | ||
<?php | ||
|
||
namespace JonoM\FocusPoint\Tests\Extensions; | ||
|
||
|
||
use JonoM\FocusPoint\Extensions\FocusPointAssetFormFactoryExtension; | ||
use SilverStripe\Assets\Folder; | ||
use SilverStripe\Assets\Image; | ||
use SilverStripe\Control\Controller; | ||
use SilverStripe\Dev\SapphireTest; | ||
use SilverStripe\Forms\FieldList; | ||
use SilverStripe\Forms\Tab; | ||
use SilverStripe\Forms\TabSet; | ||
use SilverStripe\Forms\TextField; | ||
|
||
class FocusPointAssetFormFactoryExtensionTest extends SapphireTest | ||
{ | ||
|
||
protected static $fixture_file = '../ImageManipulationTest.yml'; | ||
|
||
public function testUpdateFormFieldsOnImageEditForm() | ||
{ | ||
$ext = new FocusPointAssetFormFactoryExtension(); | ||
|
||
$fields = FieldList::create( | ||
TabSet::create( | ||
'Editor', | ||
Tab::create( | ||
'Details', | ||
TextField::create('Title') | ||
) | ||
) | ||
); | ||
$controller = new Controller(); | ||
$formName = 'fileEditForm'; | ||
$context = [ | ||
'Record' => $this->objFromFixture(Image::class, 'pngLeftTop') | ||
]; | ||
|
||
|
||
$ext->updateFormFields($fields, $controller, $formName, $context); | ||
|
||
$focusField = $fields->fieldByName('Editor.Details.FocusPoint'); | ||
$this->assertNotEmpty($focusField, 'Focus field has been added to image edit form.'); | ||
} | ||
|
||
public function testUpdateFormFieldsOnPlacementForm() | ||
{ | ||
$ext = new FocusPointAssetFormFactoryExtension(); | ||
|
||
$fields = FieldList::create( | ||
TextField::create('Title') | ||
); | ||
$controller = new Controller(); | ||
$formName = 'fileEditForm'; | ||
$context = [ | ||
'Record' => $this->objFromFixture(Image::class, 'pngLeftTop') | ||
]; | ||
|
||
|
||
$ext->updateFormFields($fields, $controller, $formName, $context); | ||
|
||
$focusField = $fields->fieldByName('Editor.Details.FocusPoint'); | ||
$this->assertEmpty($focusField, 'Focus field has NOT been added to the form.'); | ||
} | ||
|
||
public function testUpdateFormFieldsOnNonImageForm() | ||
{ | ||
$ext = new FocusPointAssetFormFactoryExtension(); | ||
|
||
$fields = FieldList::create( | ||
TabSet::create( | ||
'Editor', | ||
Tab::create( | ||
'Details', | ||
TextField::create('Title') | ||
) | ||
) | ||
); | ||
$controller = new Controller(); | ||
$formName = 'fileEditForm'; | ||
$context = [ | ||
'Record' => $this->objFromFixture(Folder::class, 'folder1') | ||
]; | ||
|
||
$ext->updateFormFields($fields, $controller, $formName, $context); | ||
|
||
$focusField = $fields->fieldByName('Editor.Details.FocusPoint'); | ||
$this->assertEmpty($focusField, 'Focus field has NOT been added to the form.'); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test against the old form layout