Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rng-3202298
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
rng-3202298
Commits
e1d96b7d
Commit
e1d96b7d
authored
8 years ago
by
dpi
Browse files
Options
Downloads
Patches
Plain Diff
Added event type entity test coverage.
Fixed failing tests, entity_form_mode not set
parent
13b33f6c
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Entity/EventType.php
+7
-3
7 additions, 3 deletions
src/Entity/EventType.php
tests/src/Kernel/RngEventMetaTest.php
+1
-1
1 addition, 1 deletion
tests/src/Kernel/RngEventMetaTest.php
tests/src/Kernel/RngEventTypeEntityTest.php
+94
-0
94 additions, 0 deletions
tests/src/Kernel/RngEventTypeEntityTest.php
with
102 additions
and
4 deletions
src/Entity/EventType.php
+
7
−
3
View file @
e1d96b7d
...
...
@@ -220,9 +220,13 @@ class EventType extends ConfigEntityBase implements EventTypeInterface {
public
function
getIdentityTypeEntityFormModes
()
{
$result
=
[];
foreach
(
$this
->
people_types
as
$people_type
)
{
$entity_type
=
$people_type
[
'entity_type'
];
$bundle
=
$people_type
[
'bundle'
];
$result
[
$entity_type
][
$bundle
]
=
$people_type
[
'entity_form_mode'
];
$required_keys
=
[
'entity_type'
,
'bundle'
,
'entity_form_mode'
];
// Ensure keys exist.
if
(
count
(
$required_keys
)
===
count
(
array_intersect_key
(
array_flip
(
$required_keys
),
$people_type
)))
{
$entity_type
=
$people_type
[
'entity_type'
];
$bundle
=
$people_type
[
'bundle'
];
$result
[
$entity_type
][
$bundle
]
=
$people_type
[
'entity_form_mode'
];
}
}
return
$result
;
}
...
...
This diff is collapsed.
Click to expand it.
tests/src/Kernel/RngEventMetaTest.php
+
1
−
1
View file @
e1d96b7d
...
...
@@ -91,7 +91,7 @@ class RngEventMetaTest extends RngKernelTestBase {
public
function
testRegistrantsMinimumNoDefaultValue
()
{
$event
=
EntityTest
::
create
();
$event_meta
=
$this
->
eventManager
->
getMeta
(
$event
);
$this
->
assertSame
(
$this
->
unlimited
,
$event_meta
->
getRegistrantsMinimum
(),
'Minimum registrants matches empty bundle default.'
);
$this
->
assertSame
(
1
,
$event_meta
->
getRegistrantsMinimum
(),
'Minimum registrants matches empty bundle default.'
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
tests/src/Kernel/RngEventTypeEntityTest.php
0 → 100644
+
94
−
0
View file @
e1d96b7d
<?php
namespace
Drupal\Tests\rng\Kernel
;
use
Drupal\simpletest\UserCreationTrait
;
use
Drupal\rng\Entity\EventType
;
/**
* Tests event type entities.
*
* @group rng
* @coversDefaultClass \Drupal\rng\Entity\EventType
*/
class
RngEventTypeEntityTest
extends
RngKernelTestBase
{
/**
* Test getting all identity type form modes.
*
* @covers ::getIdentityTypeEntityFormModes
*/
public
function
testGetIdentityTypeEntityFormModes
()
{
$people_type
=
[
'entity_type'
=>
$this
->
randomMachineName
(),
'bundle'
=>
$this
->
randomMachineName
(),
'entity_form_mode'
=>
$this
->
randomMachineName
(),
];
$values
[
'people_types'
][]
=
$people_type
;
$event_type
=
$this
->
createEventTypeBase
(
$values
);
$result
=
$event_type
->
getIdentityTypeEntityFormModes
();
$this
->
assertEquals
(
$people_type
[
'entity_form_mode'
],
$result
[
$people_type
[
'entity_type'
]][
$people_type
[
'bundle'
]]);
}
/**
* Test getting all identity type form modes when no defaults set.
*
* @covers ::getIdentityTypeEntityFormModes
*/
public
function
testGetIdentityTypeEntityFormModesNoDefaults
()
{
$values
[
'people_types'
][]
=
[
'entity_type'
=>
$this
->
randomMachineName
(),
'bundle'
=>
$this
->
randomMachineName
(),
];
$event_type
=
$this
->
createEventTypeBase
(
$values
);
$result
=
$event_type
->
getIdentityTypeEntityFormModes
();
$this
->
assertEquals
([]
,
$result
);
}
/**
* Test default registrant type defaults.
*
* @covers ::setDefaultRegistrantType
* @covers ::getDefaultRegistrantType
*/
public
function
testGetDefaultRegistrantType
()
{
$event_type
=
$this
->
createEventTypeBase
();
$registrant_type
=
$this
->
randomMachineName
();
$event_type
->
setDefaultRegistrantType
(
$registrant_type
);
$this
->
assertEquals
(
$registrant_type
,
$event_type
->
getDefaultRegistrantType
());
}
/**
* Test getting default registrant type defaults set.
*
* @covers ::getDefaultRegistrantType
*/
public
function
testGetDefaultRegistrantTypeDefault
()
{
$event_type
=
$this
->
createEventTypeBase
();
$result
=
$event_type
->
getDefaultRegistrantType
();
$this
->
assertNull
(
$result
);
}
/**
* Create a event type with only required info.
*
* @param array $values
* Default values to use when creating the event type.
*
* @return \Drupal\rng\EventTypeInterface
* An new event type entity.
*/
protected
function
createEventTypeBase
(
$values
=
[])
{
$event_type
=
EventType
::
create
(
$values
+
[
'id'
=>
$this
->
randomMachineName
(),
'label'
=>
$this
->
randomMachineName
(),
'entity_type'
=>
'entity_test'
,
'bundle'
=>
'entity_test'
,
]);
return
$event_type
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment