Skip to content

Commit a8e6c2a

Browse files
committed
Several enhancements
1 parent 6f93c42 commit a8e6c2a

File tree

5 files changed

+180
-6
lines changed

5 files changed

+180
-6
lines changed

lib/Action.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,65 @@
1111

1212
class Action
1313
{
14+
private $name = '';
15+
private $type = '';
16+
private $target;
1417

18+
/**
19+
* Action constructor.
20+
* @param string $name
21+
* @param string $type
22+
*/
23+
public function __construct(string $type)
24+
{
25+
$this->type = $type;
26+
}
27+
28+
/**
29+
* @return string
30+
*/
31+
public function getName(): string
32+
{
33+
return $this->name;
34+
}
35+
36+
/**
37+
* @param string $name
38+
*/
39+
public function setName(string $name): void
40+
{
41+
$this->name = $name;
42+
}
43+
44+
/**
45+
* @return string
46+
*/
47+
public function getType(): string
48+
{
49+
return $this->type;
50+
}
51+
52+
/**
53+
* @param string $type
54+
*/
55+
public function setType(string $type): void
56+
{
57+
$this->type = $type;
58+
}
59+
60+
/**
61+
* @return mixed
62+
*/
63+
public function getTarget()
64+
{
65+
return $this->target;
66+
}
67+
68+
/**
69+
* @param mixed $target
70+
*/
71+
public function setTarget(Model $target): void
72+
{
73+
$this->target = $target;
74+
}
1575
}

lib/Trello.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,8 @@ public function getLists(Model $board)
101101
return $lists;
102102
}
103103

104+
public function registerWebhook(Webhook)
105+
{
106+
}
107+
104108
}

lib/Webhook.php

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,81 @@
1111

1212
class Webhook
1313
{
14+
private $action;
15+
private $id;
16+
private $model;
17+
private $handle;
18+
19+
/**
20+
* @return mixed
21+
*/
22+
public function getAction()
23+
{
24+
return $this->action;
25+
}
26+
27+
/**
28+
* @param mixed $action
29+
* @return Webhook
30+
*/
31+
public function setAction($action)
32+
{
33+
$this->action = $action;
34+
return $this;
35+
}
36+
37+
/**
38+
* @return mixed
39+
*/
40+
public function getId()
41+
{
42+
return $this->id;
43+
}
44+
45+
/**
46+
* @param mixed $id
47+
* @return Webhook
48+
*/
49+
public function setId($id)
50+
{
51+
$this->id = $id;
52+
return $this;
53+
}
54+
55+
/**
56+
* @return mixed
57+
*/
58+
public function getModel()
59+
{
60+
return $this->model;
61+
}
62+
63+
/**
64+
* @param mixed $model
65+
* @return Webhook
66+
*/
67+
public function setModel($model)
68+
{
69+
$this->model = $model;
70+
return $this;
71+
}
72+
73+
/**
74+
* @return mixed
75+
*/
76+
public function getHandle()
77+
{
78+
return $this->handle;
79+
}
80+
81+
/**
82+
* @param mixed $handle
83+
* @return Webhook
84+
*/
85+
public function setHandle($handle)
86+
{
87+
$this->handle = $handle;
88+
return $this;
89+
}
1490

1591
}

tests/ActionTest.php

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,35 @@
1212

1313
class ActionTest extends \PHPUnit\Framework\TestCase
1414
{
15-
public function testObject()
15+
protected $action;
16+
17+
public function setUp(): void
18+
{
19+
}
20+
21+
public function testCreateAction()
22+
{
23+
$action = new Action("return");
24+
$action->setName('Returns the string \'Executed\'');
25+
$this->assertTrue(true);
26+
return $action;
27+
}
28+
29+
/**
30+
* @depends testCreateAction
31+
*/
32+
public function testGetName($action)
33+
{
34+
$this->assertEquals("Returns the string 'Executed'", $action->getName());
35+
}
36+
37+
/**
38+
* @depends testCreateAction
39+
*/
40+
public function testSetName($action)
1641
{
17-
$object = new Action();
18-
$this->assertIsObject($object,"Has to be an object.");
42+
$action->setName("New name");
43+
$this->assertEquals("New name", $action->getName());
1944
}
2045

2146
}

tests/TrelloTest.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,26 @@ public function init($msg = "")
1717
}
1818
}
1919

20+
public function testInit()
21+
{
22+
require ".config";
23+
$trello = new \Webhooks\Wrapper\Trello($key, $token);
24+
$this->assertTrue(true);
25+
return $trello;
26+
}
27+
2028
public function teamIdProvider()
2129
{
2230
return [['5c004b2157cb628ef3fd9362']];
2331
}
2432

2533
/**
34+
* @depends testInit
2635
* @dataProvider teamIdProvider
2736
*/
28-
public function testGetTeam($id)
37+
public function testGetTeam()
2938
{
30-
$this->init();
31-
$trello = $this->trello;
39+
list($id, $trello) = func_get_args();
3240
$team = $trello->getTeam($id);
3341
$this->assertInstanceOf("Webhooks\Wrapper\Model", $team, "Only Model object required");
3442
$this->assertEquals("team", $team->getType(), "Model should be of type team");
@@ -62,6 +70,7 @@ public function selectTestTeamProvider()
6270
}
6371

6472
/**
73+
* @depends testInit
6574
* @dataProvider teamsProvider
6675
*/
6776
public function testGetTeamsReturnedModels($model)

0 commit comments

Comments
 (0)