Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
date_recur-3074723
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
date_recur-3074723
Commits
b49c6d38
Commit
b49c6d38
authored
3 years ago
by
dpi
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3153976
by AndyF: Can't iterate DateRecurNonRecurringHelper
parent
116c83b9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/DateRecurNonRecurringHelper.php
+1
-1
1 addition, 1 deletion
src/DateRecurNonRecurringHelper.php
tests/src/Unit/DateRecurNonRecurringHelperUnitTest.php
+26
-0
26 additions, 0 deletions
tests/src/Unit/DateRecurNonRecurringHelperUnitTest.php
with
27 additions
and
1 deletion
src/DateRecurNonRecurringHelper.php
+
1
−
1
View file @
b49c6d38
...
@@ -126,7 +126,7 @@ class DateRecurNonRecurringHelper implements DateRecurHelperInterface {
...
@@ -126,7 +126,7 @@ class DateRecurNonRecurringHelper implements DateRecurHelperInterface {
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
valid
():
bool
{
public
function
valid
():
bool
{
return
TRUE
;
return
!
is_null
(
key
(
$this
->
occurrences
))
;
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
tests/src/Unit/DateRecurNonRecurringHelperUnitTest.php
+
26
−
0
View file @
b49c6d38
...
@@ -94,6 +94,32 @@ class DateRecurNonRecurringHelperUnitTest extends UnitTestCase {
...
@@ -94,6 +94,32 @@ class DateRecurNonRecurringHelperUnitTest extends UnitTestCase {
);
);
}
}
/**
* Test the helper works as an iterator.
*/
public
function
testIteration
()
{
$format
=
'ga j F Y'
;
$start
=
'2am 14 April 2014'
;
$end
=
'4am 14 April 2014'
;
$helper
=
$this
->
createHelper
(
new
\DateTime
(
$start
),
new
\DateTime
(
$end
)
);
$occurrences
=
[];
// Iterate the occurences.
foreach
(
$helper
as
$date_range
)
{
$occurrences
[]
=
$date_range
;
}
// There should be only one result.
/** @var \Drupal\date_recur\DateRange $occurrence */
$occurrence
=
reset
(
$occurrences
);
$this
->
assertCount
(
1
,
$occurrences
);
$this
->
assertSame
(
$occurrence
->
getStart
()
->
format
(
$format
),
$start
);
$this
->
assertSame
(
$occurrence
->
getEnd
()
->
format
(
$format
),
$end
);
}
/**
/**
* Creates a new helper.
* Creates a new helper.
*
*
...
...
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