Skip to content

Commit

Permalink
getting testing back up
Browse files Browse the repository at this point in the history
  • Loading branch information
edalzell committed Jul 9, 2020
1 parent 92a8f47 commit a2c9757
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 35 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.DS_Store
/vendor
/composer.lock
17 changes: 15 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,29 @@
"Edalzell\\Pinboard\\Test\\": "tests"
}
},
"autoload-dev": {
"psr-4": {
"Silentz\\Charge\\Tests\\": "tests"
}
},
"require": {
"kijin/pinboard-api": ">=0.3.0"
"kijin/pinboard-api": ">=0.3.0",
"php": "^7.4"
},
"require-dev": {
"statamic/cms": "3.0.*@beta",
"mockery/mockery": "~1.0",
"orchestra/testbench": "^5.0",
"phpunit/phpunit": "^9.0",
"nunomaduro/collision": "^4.2"
},
"authors": [
{
"name": "Erin Dalzell"
}
],
"support": {
"email": "erin@silentzconsulting.com"
"email": "erin@silentz.co"
},
"extra": {
"statamic": {
Expand Down
29 changes: 27 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,35 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer">
verbose="true"
printerClass="NunoMaduro\Collision\Adapters\Phpunit\Printer">
<testsuites>
<testsuite name="Tests">
<testsuite name="Unit">
<directory suffix="Test.php">tests/Unit/</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">tests/Feature/</directory>
</testsuite>
<testsuite name="Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_KEY" value="base64:xRIcDp1ReW8Y8rd9V9D7hOVV4TI7ThCF3FKxRg01Rm8="/>
<env name="APP_URL" value="http://v3.test"/>
<env name="DB_CONNECTION" value="mysql" />
<env name="DB_DATABASE" value="charge-test" />
<env name="DB_USERNAME" value="root" />
<env name="DB_PASSWORD" value="root" />
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="MAIL_DRIVER" value="array"/>
</php>
</phpunit>
3 changes: 1 addition & 2 deletions src/FakePinboardGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

namespace Edalzell\Pinboard;

use Statamic\API\Arr;
use Illuminate\Support\Facades\Cache;
use Statamic\Support\Arr;

class FakePinboardGateway implements BookmarkGateway
{

public function add($bookmark)
{
$this->bookmarks[] = $bookmark;
Expand Down
14 changes: 7 additions & 7 deletions src/Pinboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Edalzell\Pinboard;

use Log;
use Statamic\API\Str;
use Statamic\API\Site;
use Statamic\API\Entry;
use Statamic\API\Search;
use Illuminate\Support\Arr;
use Statamic\API\Collection;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Artisan as Please;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
use Statamic\Entries\Entry;
use Statamic\Facades\Collection;
use Statamic\Facades\Search;
use Statamic\Facades\Site;
use Statamic\Support\Str;

class Pinboard
{
Expand Down
40 changes: 18 additions & 22 deletions tests/PinboardTest.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<?php

use Tests\TestCase;
use Statamic\API\Entry;
use Carbon\CarbonImmutable;
use Statamic\API\Collection;
use Edalzell\Pinboard\Bookmark;
use Edalzell\Pinboard\Pinboard;
use Edalzell\Pinboard\BookmarkGateway;
use Tests\PreventSavingStacheItemsToDisk;
use Edalzell\Pinboard\FakePinboardGateway;
use Edalzell\Pinboard\Pinboard;
use Illuminate\Support\Facades\Cache;
use Orchestra\Testbench\TestCase;
use Statamic\Facades\Collection;
use Statamic\Facades\Entry;

class PinboardTest extends TestCase
{
use PreventSavingStacheItemsToDisk;

/** @var Pinboard */
private $pinboard;

Expand Down Expand Up @@ -61,12 +59,11 @@ public function can_add_entry_from_bookmark()
'text' => $description,
];

Collection::create('blog')->save();
Collection::make('blog')->save();

$this->gateway->add($bookmark);
$this->pinboard->write($this->gateway->bookmarks(), 'blog');

/** @var \Statamic\API\Entry */
$entry = Entry::findBySlug('this-is-a-title', 'blog');
$content_block = $entry->get('content_block');

Expand All @@ -81,9 +78,9 @@ public function can_get_recent_from_timestamp()
{
for ($x = 0; $x < 5; $x++) {
$bookmark = new Bookmark(
'http://url.com/bookmark' . $x,
'Title ' . $x,
'Description ' . $x,
'http://url.com/bookmark'.$x,
'Title '.$x,
'Description '.$x,
now()->subSeconds($x + 1)
);
$this->gateway->add($bookmark);
Expand All @@ -102,9 +99,9 @@ public function can_get_recent_from_timestamp()

// the right bookmarks?
for ($x = 0; $x < 3; $x++) {
$this->assertEquals('http://url.com/bookmark' . $x, $bookmarks[$x]->url);
$this->assertEquals('Title ' . $x, $bookmarks[$x]->title);
$this->assertEquals('Description ' . $x, $bookmarks[$x]->description);
$this->assertEquals('http://url.com/bookmark'.$x, $bookmarks[$x]->url);
$this->assertEquals('Title '.$x, $bookmarks[$x]->title);
$this->assertEquals('Description '.$x, $bookmarks[$x]->description);
$this->assertGreaterThanOrEqual($from, $bookmarks[$x]->timestamp);
}
}
Expand All @@ -115,9 +112,9 @@ public function can_get_recent_from_cache()
$now = CarbonImmutable::now();
for ($x = 0; $x < 5; $x++) {
$bookmark = new Bookmark(
'http://url.com/bookmark' . $x,
'Title ' . $x,
'Description ' . $x,
'http://url.com/bookmark'.$x,
'Title '.$x,
'Description '.$x,
$now->subSeconds($x + 1)
);
$this->gateway->add($bookmark);
Expand All @@ -131,11 +128,10 @@ public function can_get_recent_from_cache()
$this->assertCount(3, $bookmarks);

for ($x = 0; $x < 3; $x++) {
$this->assertEquals('http://url.com/bookmark' . $x, $bookmarks[$x]->url);
$this->assertEquals('Title ' . $x, $bookmarks[$x]->title);
$this->assertEquals('Description ' . $x, $bookmarks[$x]->description);
$this->assertEquals('http://url.com/bookmark'.$x, $bookmarks[$x]->url);
$this->assertEquals('Title '.$x, $bookmarks[$x]->title);
$this->assertEquals('Description '.$x, $bookmarks[$x]->description);
$this->assertGreaterThanOrEqual($from, $bookmarks[$x]->timestamp);
}
}

}

0 comments on commit a2c9757

Please sign in to comment.