-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAxcelerateTest.php
More file actions
129 lines (102 loc) · 3.29 KB
/
Copy pathAxcelerateTest.php
File metadata and controls
129 lines (102 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
namespace Tests\Unit;
use FlipNinja\Axcelerate\Axcelerate;
use FlipNinja\Axcelerate\Contacts\Contact;
use FlipNinja\Axcelerate\Contacts\ContactManager;
use FlipNinja\Axcelerate\Courses\CourseManager;
use FlipNinja\Axcelerate\Courses\Instance;
use Illuminate\Support\Facades\Log;
use PHPUnit\Framework\TestCase;
use Dotenv\Dotenv;
class AxcelerateTest extends TestCase
{
private $axcelerate;
protected function setUp()
{
$dotenv = Dotenv::createImmutable(__DIR__ . '/../..');
$dotenv->load();
$this->axcelerate = new Axcelerate($_ENV['AXCELERATE_APITOKEN'], $_ENV['AXCELERATE_WSTOKEN'], $_ENV['AXCELERATE_URL']);
}
public function testContactsReturnsContactManager()
{
$this->assertInstanceOf(
ContactManager::class,
$this->axcelerate->contacts()
);
}
public function testCoursesReturnCourseManager()
{
$this->assertInstanceOf(
CourseManager::class,
$this->axcelerate->courses()
);
}
public function testSingletonsAreReturned()
{
$this->assertEquals(
spl_object_hash($this->axcelerate->contacts()),
spl_object_hash($this->axcelerate->contacts())
);
$this->assertEquals(
spl_object_hash($this->axcelerate->courses()),
spl_object_hash($this->axcelerate->courses())
);
}
public function testInstanceSearch()
{
$instance = $this->axcelerate->courses()->findInstance([
'InstanceID' => 1975636
]);
$this->assertInstanceOf(
Instance::class,
$instance
);
print_r($instance);
}
public function testInstanceCreate()
{
$instance = $this->axcelerate->courses()->createInstance([
'trainerContactID' => 14192049,
'name' => 'API test Created UnitTest',
'startDate' => '2024/08/10',
'finishDate' => '2024/08/11',
'startTime' => '9:00:00',
'finishTime' => '10:00:00',
'type' => 'w',
'ID' => 110190
]);
$this->assertTrue(is_int($instance), 'Instance creation should return an integer.');
}
public function testInstanceUpdate()
{
$instanceUpdated = $this->axcelerate->courses()->updateInstance([
'ProgramName' => 'Instance Updated using UnitTest',
'type' => 'w',
'ID' => 1975636
]);
$this->assertTrue($instanceUpdated);
}
public function testContactSearch()
{
$contact = $this->axcelerate->contacts()->findByEmail('devcontact@antero.com.au');
$this->assertInstanceOf(
Contact::class,
$contact
);
// $enrolments = $contact->enrolments();
// foreach ($enrolments as $enrolment) {
// print_r($enrolment);die;
// $certificate = $contact->certificate($enrolment['ENROLID']);
// print_r($certificate);
// }
}
public function testEnrollment()
{
$invoice = $this->axcelerate->courses()->enrollment([
'contactID' => 14192049,
'type' => 'w',
'instanceID' => 1975636
]);
$this->assertTrue(is_int($invoice), 'Enrollment should return an integer.');
}
}