Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
Doorcode
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Guardians of the Kretschmar Elock System
Doorcode
Commits
082d4234
Commit
082d4234
authored
Dec 13, 2020
by
Jacob Priddy
👌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests for new override architecture
parent
b9445689
Pipeline
#13198
failed with stages
in 1 minute and 12 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
91 additions
and
11 deletions
+91
-11
src/backend/src/Entities/SplittableDate.php
src/backend/src/Entities/SplittableDate.php
+1
-6
src/backend/src/Gateways/DoorSchedule/DoorScheduleRepository.php
...kend/src/Gateways/DoorSchedule/DoorScheduleRepository.php
+1
-1
src/backend/src/UseCases/Door/Access/AccessUseCase.php
src/backend/src/UseCases/Door/Access/AccessUseCase.php
+1
-1
src/backend/tests/Unit/Source/Entities/SplittableDateTest.php
...backend/tests/Unit/Source/Entities/SplittableDateTest.php
+12
-0
src/backend/tests/Unit/Source/UseCases/Door/ScheduleEvents/ScheduleEventsTest.php
...ource/UseCases/Door/ScheduleEvents/ScheduleEventsTest.php
+76
-3
No files found.
src/backend/src/Entities/SplittableDate.php
View file @
082d4234
...
...
@@ -108,23 +108,18 @@ class SplittableDate
$prev
=
array_shift
(
$set
);
$noMerge
=
true
;
foreach
(
$set
as
$item
)
{
if
(
$item
->
getBegin
()
<=
$prev
->
getEnd
())
{
if
(
$prev
->
getEnd
()
<
$item
->
getEnd
())
{
$prev
->
setEnd
(
$item
->
getEnd
());
}
$noMerge
=
true
;
}
else
{
$merged
[]
=
$prev
;
$noMerge
=
false
;
$prev
=
$item
;
}
}
if
(
$noMerge
)
{
$merged
[]
=
$prev
;
}
$merged
[]
=
$prev
;
return
$merged
;
}
...
...
src/backend/src/Gateways/DoorSchedule/DoorScheduleRepository.php
View file @
082d4234
...
...
@@ -18,7 +18,7 @@ interface DoorScheduleRepository
* @param string $doorId
* @param \Carbon\Carbon $begin
* @param \Carbon\Carbon $end
* @param int
|null
$type
* @param int
$type
* @return \Source\Entities\Schedule[]
*/
public
function
getSchedulesForDoorBetween
(
string
$doorId
,
Carbon
$begin
,
Carbon
$end
,
int
$type
=
Schedule
::
TYPE_OPEN_MODE
):
array
;
...
...
src/backend/src/UseCases/Door/Access/AccessUseCase.php
View file @
082d4234
...
...
@@ -10,7 +10,7 @@ interface AccessUseCase
{
/**
* @param \Source\Entities\Door|null $door
* @param string
|null
$doorcode
* @param string
$doorcode
* @param \Carbon\Carbon $date
* @throws \Source\Exceptions\AuthenticationException
* @throws \Source\Exceptions\AuthorizationException
...
...
src/backend/tests/Unit/Source/Entities/SplittableDateTest.php
View file @
082d4234
...
...
@@ -126,4 +126,16 @@ class SplittableDateTest extends TestCase
$toSplit
=
new
SplittableDate
(
Carbon
::
now
()
->
subMinute
(),
Carbon
::
now
()
->
addMinute
());
$this
->
assertEquals
([],
$toSplit
->
split
([
$toSplit
]));
}
/** @test */
public
function
test_merge_end_on_no_merge
():
void
{
$d1
=
new
SplittableDate
(
Carbon
::
now
()
->
addMinute
(),
Carbon
::
now
()
->
addMinutes
(
3
));
$d2
=
new
SplittableDate
(
Carbon
::
now
()
->
addMinutes
(
5
),
Carbon
::
now
()
->
addMinutes
(
10
));
$result
=
SplittableDate
::
mergeSet
([
$d1
,
$d2
]);
$this
->
assertCount
(
2
,
$result
);
$this
->
assertEquals
(
$d1
,
$result
[
0
]);
$this
->
assertEquals
(
$d2
,
$result
[
1
]);
}
}
src/backend/tests/Unit/Source/UseCases/Door/ScheduleEvents/ScheduleEventsTest.php
View file @
082d4234
...
...
@@ -7,6 +7,7 @@ use Carbon\Carbon;
use
Source\Entities\Override
;
use
Source\Entities\Schedule
;
use
PHPUnit\Framework\TestCase
;
use
Source\Entities\SplittableDate
;
use
Tests\Doubles\RecurrenceSetStub
;
use
Source\UseCases\Door\ScheduleEvents\ResponseModel
;
use
Source\UseCases\Door\ScheduleEvents\ScheduleEvents
;
...
...
@@ -81,7 +82,7 @@ class ScheduleEventsTest extends TestCase
*/
public
function
it_adds_override_events
():
void
{
$o
verride
=
$this
->
overrides
->
addOverride
(
new
Override
(
$o
1
=
$this
->
overrides
->
addOverride
(
new
Override
(
1
,
'ree'
,
1
,
...
...
@@ -91,10 +92,21 @@ class ScheduleEventsTest extends TestCase
Carbon
::
now
()
->
addMinute
()
));
$this
->
handleTest
(
'1'
,
Carbon
::
now
(),
Carbon
::
now
()
->
addSeconds
(
30
));
$o2
=
$this
->
overrides
->
addOverride
(
new
Override
(
1
,
'ree'
,
1
,
1
,
Override
::
TYPE_OPEN
,
Carbon
::
now
()
->
addseconds
(
40
),
Carbon
::
now
()
->
addMinutes
(
10
)
));
$this
->
handleTest
(
'1'
,
Carbon
::
now
(),
Carbon
::
now
()
->
addSeconds
(
50
));
self
::
assertCount
(
1
,
$this
->
response
->
getOpenEvents
());
self
::
assertEquals
(
$override
->
getBegin
(),
$this
->
response
->
getOpenEvents
()[
0
]
->
getBegin
());
self
::
assertEquals
(
$o1
->
getBegin
(),
$this
->
response
->
getOpenEvents
()[
0
]
->
getBegin
());
self
::
assertEquals
(
$o2
->
getEnd
(),
$this
->
response
->
getOpenEvents
()[
0
]
->
getEnd
());
}
/**
...
...
@@ -162,6 +174,67 @@ class ScheduleEventsTest extends TestCase
self
::
assertEquals
(
$this
->
rset
->
occurrences
[
0
]
->
addRealSeconds
(
60
*
20
),
$this
->
response
->
getOpenEvents
()[
1
]
->
getEnd
());
}
/**
* @test
* @throws \Source\Exceptions\EntityNotFoundException
*/
public
function
it_chops_a_schedule_with_multiple_overrides
():
void
{
$this
->
rset
->
occurrences
=
[
Carbon
::
now
()
];
$o1
=
$this
->
overrides
->
addOverride
(
new
Override
(
1
,
''
,
1
,
1
,
Override
::
TYPE_LOCKED
,
Carbon
::
now
()
->
addMinute
(),
Carbon
::
now
()
->
addMinutes
(
3
)
));
$o2
=
$this
->
overrides
->
addOverride
(
new
Override
(
1
,
''
,
1
,
1
,
Override
::
TYPE_LOCKED
,
Carbon
::
now
()
->
addMinutes
(
5
),
Carbon
::
now
()
->
addMinutes
(
10
)
));
$this
->
overrides
->
addOverride
(
new
Override
(
1
,
''
,
1
,
2
,
Override
::
TYPE_LOCKED
,
Carbon
::
now
()
->
addMinutes
(
2
),
Carbon
::
now
()
->
addMinutes
(
6
)
));
$this
->
doorSchedules
->
attachScheduleToDoor
(
'1'
,
new
Schedule
(
1
,
Schedule
::
TYPE_OPEN_MODE
,
''
,
60
*
20
,
'desc'
,
Carbon
::
now
()
->
addSeconds
(
10
)
));
$this
->
handleTest
(
'1'
,
Carbon
::
now
()
->
subMinute
(),
Carbon
::
now
()
->
addMinutes
(
30
));
self
::
assertCount
(
3
,
$this
->
response
->
getOpenEvents
());
self
::
assertEquals
(
$this
->
rset
->
occurrences
[
0
],
$this
->
response
->
getOpenEvents
()[
0
]
->
getBegin
());
self
::
assertEquals
(
$o1
->
getBegin
(),
$this
->
response
->
getOpenEvents
()[
0
]
->
getEnd
());
self
::
assertEquals
(
$o1
->
getEnd
(),
$this
->
response
->
getOpenEvents
()[
1
]
->
getBegin
());
self
::
assertEquals
(
$o2
->
getBegin
(),
$this
->
response
->
getOpenEvents
()[
1
]
->
getEnd
());
self
::
assertEquals
(
$o2
->
getEnd
(),
$this
->
response
->
getOpenEvents
()[
2
]
->
getBegin
());
self
::
assertEquals
(
$this
->
rset
->
occurrences
[
0
]
->
addRealSeconds
(
60
*
20
),
$this
->
response
->
getOpenEvents
()[
2
]
->
getEnd
());
}
/**
* @test
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment