Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Nov 3, 2017
1 parent ca75cd4 commit 6edac26
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@ build
composer.lock
docs
vendor
tests/ApiTest.php
4 changes: 2 additions & 2 deletions src/Actions/ManagesSites.php
Expand Up @@ -18,14 +18,14 @@ public function site(int $siteId): Site
{
$siteAttributes = $this->get("sites/{$siteId}");

return new Site($siteAttributes);
return new Site($siteAttributes, $this);
}

public function createSite(array $data): Site
{
$siteAttributes = $this->post("sites", $data);

return new Site($siteAttributes);
return new Site($siteAttributes, $this);
}

public function deleteSite(int $siteId)
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/Site.php
Expand Up @@ -32,7 +32,7 @@ class Site extends Resource
*/
public function delete()
{
$this->ohDear->deleteSite($this->serverId, $this->id);
$this->ohDear->deleteSite($this->id);
}
}

39 changes: 39 additions & 0 deletions tests/ApiTest.php
@@ -0,0 +1,39 @@
<?php

namespace Tests;

use GuzzleHttp\Client;
use OhDear\PhpSdk\OhDear;
use PHPUnit\Framework\TestCase;

class ApiTest extends TestCase
{
/** @test */
public function it_tests()
{
//production
//$apiKey = 'H3VPxvHDyAQ8zMr3WxIrUJHoZsImk0TQMffp9rrpe7xBwbc9332mGqUXTqkX';

//test
$apiKey = 'c2nh018eM1pTjqfbuF90ILuscZwlBISVPj7tJB8laoWS1Sg2jgf8FBlIIkgB';

$testClient = new Client([
'base_uri' => 'http://ohdearapp.com.dev/api/',
'http_errors' => false,
'headers' => [
'Authorization' => 'Bearer '.$apiKey,
'Accept' => 'application/json',
'Content-Type' => 'application/json'
]
]);

$ohDear = new OhDear($apiKey, $testClient);

var_dump($site = $ohDear->site(2));
$site->delete();
die();
$this->info('creating site https://newsite.com');
$ohDear->createSite(['url' => 'https://newsite.com', 'team_id' => 2]);
$this->info('done');
}
}

0 comments on commit 6edac26

Please sign in to comment.