/
EventReviewTest.php
66 lines (60 loc) · 2.64 KB
/
EventReviewTest.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
58
59
60
61
62
63
64
65
66
<?php
namespace Oriskami;
class EventReviewTest extends TestCase
{
public function __construct()
{
self::authorizeFromEnv();
// CRUD ___________________________________
// Created ...
$created = EventReview::update("1", array("reviewer_id" => "125", "message" => "another review"));
$this->created = $created[count($created) - 1];
// Retrieve ...
$this->retrieved = EventReview::retrieve("1")[0];
// Update .....
$this->updated1 = EventReview::update("1", array("review_id" => 0, "reviewer_id" => "124"))[0];
$this->updated2 = EventReview::update("1", array("review_id" => 0, "reviewer_id" => "123"))[0];
// List .......
$this->listed = EventReview::all(array("order" => "id"));
// Delete .....
$this->deleted = EventReview::delete("1", array("review_id" => 2))[0];
}
public function testExists()
{
self::log(__METHOD__, "Should exist" );
$this->assertNotNull($this->retrieved );
$this->assertNotNull($this->updated1 );
$this->assertNotNull($this->updated2 );
$this->assertNotNull($this->deleted );
$this->assertNotNull($this->listed );
}
public function testClass()
{
self::log(__METHOD__, "Should have the right class");
$this->assertInstanceOf("Oriskami\\EventReview", $this->retrieved);
$this->assertInstanceOf("Oriskami\\EventReview", $this->updated1 );
$this->assertInstanceOf("Oriskami\\EventReview", $this->updated2 );
$this->assertInstanceOf("Oriskami\\EventReview", $this->deleted );
$this->assertInstanceOf("Oriskami\\EventReview", $this->listed[0]);
$this->assertInstanceOf("Oriskami\\EventReview", $this->listed[1]);
}
public function testId()
{
self::log(__METHOD__, "Should have the right 'id'");
$this->assertEquals($this->retrieved->id, "1");
$this->assertEquals($this->updated1->id , "1");
$this->assertEquals($this->updated2->id , "1");
$this->assertEquals($this->deleted->id , "1");
$this->assertEquals($this->listed[0]->id, "1");
$this->assertEquals($this->listed[1]->id, "1");
}
public function testAttr()
{
self::log(__METHOD__, "Should have the expected attributes");
$this->assertEquals( $this->created->reviewer["id"]."", "125");
$this->assertEquals( $this->updated1->reviewer["id"]."", "124");
$this->assertEquals( $this->updated2->reviewer["id"]."", "123");
$this->assertEquals( count($this->deleted), 1);
$this->assertTrue(count($this->listed) > 0);
}
}