-
Notifications
You must be signed in to change notification settings - Fork 16
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
FieldType context #24
Merged
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
46e0e87
Basic functionality for the fieldType Context and ObjectManager
a2ddee1
Added optional name to the create a field sentence
39ed556
Fieldtype Behat sentences implementation
ff5489e
added default value to fieldtype
dbe167c
removed incompatible constructor
f7a7f27
fixed bug with empty field values
214af30
Refactor improved executeDelayedAction method
34a12fd
Refactor FIELD constant to FIELD_TYPE
d820bef
Refactor splitline comment
84b11a2
Refactor rename instantiate to createContenttype
4b6568b
Refactor removed not used constant
f2d77cf
Fix mistaked removed line
2640cc9
removed unnecessary sentence/method
d39ddb8
improved comments
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
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,84 @@ | ||
<?php | ||
/** | ||
* File containing the Content Type context | ||
* | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
* @version //autogentag// | ||
*/ | ||
|
||
namespace EzSystems\BehatBundle\Context\Object; | ||
|
||
use Behat\Gherkin\Node\TableNode; | ||
use PHPUnit_Framework_Assert as Assertion; | ||
|
||
/** | ||
* Sentences for Fields | ||
*/ | ||
trait FieldType | ||
{ | ||
/** | ||
* @Given a Content Type with an :fieldType Field exists | ||
* @Given a Content Type with an :fieldType Field with Name :name exists | ||
* | ||
* Creates a ContentType with only the desired FieldType | ||
*/ | ||
public function createContentTypeWithFieldType( $fieldType, $name = null ) | ||
{ | ||
return $this->getFieldTypeManager()->createField( $fieldType, $name ); | ||
} | ||
|
||
/** | ||
* @Given a Content Type with a required :fieldType Field exists | ||
* @Given a Content Type with a required :fieldType Field with Name :name exists | ||
* | ||
* Creates a ContentType with only the desired FieldType | ||
*/ | ||
public function createContentTypeWithRequiredFieldType( $fieldType, $name = null ) | ||
{ | ||
return $this->getFieldTypeManager()->createField( $fieldType, $name, true ); | ||
} | ||
|
||
/** | ||
* @Given a Content of this type exists | ||
* @Given a Content of this type exists with :field Field Value set to :value | ||
* @And a Content of this type exists | ||
* @And a Content of this type exists with :field Field Value set to :value | ||
* | ||
* Creates a Content with the previously defined ContentType | ||
*/ | ||
public function createContentOfThisType( $field = null, $value = null ) | ||
{ | ||
return $this->getFieldTypeManager()->createContent( $field, $value ); | ||
} | ||
|
||
/** | ||
* @Given a Content Type with an :fieldType Field exists with Properties: | ||
* @Given a Content Type with an :fieldType Field with Name :name exists with Properties: | ||
*/ | ||
public function createContentOfThisTypeWithProperties( $fieldType, TableNode $properties, $name = null ) | ||
{ | ||
$this->getFieldTypeManager()->createField( $fieldType, $name ); | ||
foreach ( $properties as $property ) | ||
{ | ||
if ( $property[ 'Validator' ] == 'maximum value validator' ) | ||
{ | ||
$this->getFieldTypeManager()->addValueConstraint( $fieldType, $property[ 'Value' ], "max" ); | ||
} | ||
else if ( $property[ 'Validator' ] == 'minimum value validator' ) | ||
{ | ||
$this->getFieldTypeManager()->addValueConstraint( $fieldType, $property[ 'Value' ], "min" ); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @Then I should have an "integer" field | ||
* | ||
* Creates a Content with the previously defined ContentType | ||
*/ | ||
public function verifyContentOfType() | ||
{ | ||
// return $this->getFieldTypeManager()->executeDelayedOperations(); | ||
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. why is this not doing anything? |
||
} | ||
} |
Oops, something went wrong.
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.
doesn't seem to do anything else then method above, missing something?
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.
One creates a required field, the other one a non-required one.
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.
Ah, I was missing the
true
and thought the line where completely the same, indeed :)