/
NotifierWebhookTest.php
57 lines (52 loc) · 2.16 KB
/
NotifierWebhookTest.php
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
<?php
namespace Oriskami;
class NotifierWebhookTest extends TestCase
{
public function __construct()
{
self::authorizeFromEnv();
// CRUD ___________________________________
// Created ...
$this->created = NotifierWebhook::create(array(
"value" => "some pattern"
, "is_active" => "false"
, "description" => "a description"
));
// Update .....
$this->updated1 = NotifierWebhook::update("0", array("is_active" => "true"));
$this->updated2 = NotifierWebhook::update("0", array("is_active" => "false"));
// List .....
$this->listed1 = NotifierWebhook::all();
// Delete .....
$this->deleted = NotifierWebhook::delete(count($this->listed1) - 1);
}
public function testExists()
{
self::log(__METHOD__, "Should exist" );
$this->assertNotNull($this->created );
$this->assertNotNull($this->updated1 );
$this->assertNotNull($this->updated2 );
$this->assertNotNull($this->deleted );
$this->assertNotNull($this->listed1 );
}
public function testClass()
{
self::log(__METHOD__, "Should have the right class");
$this->assertInstanceOf("Oriskami\\NotifierWebhook", $this->updated1[0]);
$this->assertInstanceOf("Oriskami\\NotifierWebhook", $this->updated1[0]);
$this->assertInstanceOf("Oriskami\\NotifierWebhook", $this->updated2[0]);
$this->assertInstanceOf("Oriskami\\NotifierWebhook", $this->listed1[0]);
}
public function testAttr()
{
self::log(__METHOD__, "Should have the expected attributes");
$lastId = count($this->created) - 1;
$created = $this->created[$lastId];
$this->assertEquals( $created["is_active"]."", "false");
$this->assertEquals( $created["value"] , "some pattern");
$this->assertEquals( $created["description"], "a description");
$this->assertEquals( $this->updated1[0]["is_active"]."", "true");
$this->assertEquals( $this->updated2[0]["is_active"]."", "false");
$this->assertEquals( count($this->listed1) - 1, count($this->deleted));
}
}