This repository was archived by the owner on Apr 24, 2020. It is now read-only.
File tree 3 files changed +111
-0
lines changed
3 files changed +111
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Tests \Unit ;
4
+
5
+ use App \LdapDomain ;
6
+ use Tests \TestCase ;
7
+ use Illuminate \Foundation \Testing \RefreshDatabase ;
8
+
9
+ class LdapDomainTest extends TestCase
10
+ {
11
+ use RefreshDatabase;
12
+
13
+ public function test_to_synchronize_returns_models_to_synchronize_with_proper_frequency ()
14
+ {
15
+ $ this ->assertCount (0 , LdapDomain::toSynchronize ());
16
+
17
+ $ domain = factory (LdapDomain::class)->create ();
18
+ $ this ->assertCount (1 , LdapDomain::toSynchronize ());
19
+
20
+ // Default is 15 minutes.
21
+ $ domain ->scans ()->create (['started_at ' => now ()->subMinutes (15 )]);
22
+
23
+ $ toSync = LdapDomain::toSynchronize ();
24
+ $ this ->assertCount (1 , $ toSync );
25
+ $ this ->assertTrue ($ domain ->is ($ toSync ->first ()));
26
+
27
+ setting ()->set ('app.scan.frequency ' , 20 );
28
+ $ this ->assertCount (0 , LdapDomain::toSynchronize ());
29
+ }
30
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Tests \Unit \System ;
4
+
5
+ use Tests \TestCase ;
6
+ use App \System \TaskTrigger ;
7
+ use App \System \ScheduledTask ;
8
+ use Illuminate \Support \Str ;
9
+ use Illuminate \Support \Facades \File ;
10
+
11
+ class ScheduledTaskTest extends TestCase
12
+ {
13
+ public function test_default_triggers ()
14
+ {
15
+ $ task = new ScheduledTask ();
16
+ $ this ->assertContainsOnlyInstancesOf (TaskTrigger::class, $ task ->triggers ());
17
+ }
18
+
19
+ public function test_path ()
20
+ {
21
+ $ task = new ScheduledTask ();
22
+ $ task ->name = 'Test ' ;
23
+ $ this ->assertTrue (Str::contains ($ task ->path (), 'storage\app\Test.xml ' ));
24
+ }
25
+
26
+ public function test_command ()
27
+ {
28
+ $ task = new ScheduledTask ();
29
+ $ task ->name = 'Test ' ;
30
+ $ this ->assertEquals ('schtasks /Create /TN "Test" /XML "C:\laragon\www\Scout\storage\app\Test.xml" /F ' , $ task ->command ());
31
+ }
32
+
33
+ public function test_create ()
34
+ {
35
+ $ task = new ScheduledTask ();
36
+ $ task ->name = 'Test ' ;
37
+ File::shouldReceive ('put ' )->withArgs ([$ task ->path (), $ task ->toXml ()])->once ();
38
+ $ this ->assertEquals ($ task ->path (), $ task ->create ());
39
+ }
40
+
41
+ public function test_exists ()
42
+ {
43
+ $ task = new ScheduledTask ();
44
+ $ task ->name = 'Test ' ;
45
+
46
+ File::shouldReceive ('exists ' )->withArgs ([$ task ->path ()])->once ()->andReturnTrue ();
47
+ $ this ->assertTrue ($ task ->exists ());
48
+ }
49
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Tests \Unit \System ;
4
+
5
+ use Tests \TestCase ;
6
+ use App \System \TaskTrigger ;
7
+
8
+ class TaskTriggerTest extends TestCase
9
+ {
10
+ public function test_trigger_is_enabled_by_default ()
11
+ {
12
+ $ this ->assertEquals ('true ' , (new TaskTrigger )->Enabled );
13
+ }
14
+
15
+ public function test_root_element_name_can_be_set ()
16
+ {
17
+ $ trigger = new TaskTrigger ();
18
+ $ trigger ->setRootElementName ('Test ' );
19
+ $ this ->assertEquals ('Test ' , $ trigger ->getRootElementName ());
20
+ $ this ->assertEquals (['Enabled ' => 'true ' ], $ trigger ->getAttributes ());
21
+ }
22
+
23
+ public function test_trigger_types_populate_root_element ()
24
+ {
25
+ $ this ->assertEquals ('BootTrigger ' , TaskTrigger::boot ()->getRootElementName ());
26
+ $ this ->assertEquals ('CalendarTrigger ' , TaskTrigger::calendar ()->getRootElementName ());
27
+ $ this ->assertEquals ('RegistrationTrigger ' , TaskTrigger::registration ()->getRootElementName ());
28
+ $ this ->assertEquals ('IdleTrigger ' , TaskTrigger::idle ()->getRootElementName ());
29
+ $ this ->assertEquals ('LogonTrigger ' , TaskTrigger::logon ()->getRootElementName ());
30
+ $ this ->assertEquals ('SessionStateChangeTrigger ' , TaskTrigger::sessionStateChange ()->getRootElementName ());
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments