diff --git a/.gitignore b/.gitignore index 57872d0..2085207 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /vendor/ +/.phpunit.result.cache +.idea diff --git a/index.php b/index.php index 0b8dbf4..d32efb1 100644 --- a/index.php +++ b/index.php @@ -11,13 +11,12 @@ use Lewisdale\Webmentions\Router\Response; use Lewisdale\Webmentions\Router\StatusCode; use Lewisdale\Webmentions\Webmention; -$mentioner = new Webmention(); - $router = new Router(); -$router->post("/send", function(Request $req, Response $response) use ($webmention) { - $source = $req->query["source"]; - $webmention->sendForPage($source); +$router->post("/send", function(Request $req, Response $response) { + $mentioner = new Webmention(); + $source = $req->query["source"]; + $mentioner->sendForPage($source); }); $router->post("/endpoint", function(Request $req, Response $response) { @@ -39,6 +38,5 @@ $router->post("/endpoint", function(Request $req, Response $response) { $response->status_code = StatusCode::Created; }); -$router->dispatch(); - -?> \ No newline at end of file +$router->get('/', fn($req, $res) => "

Webmention server

"); +$router->dispatch(); \ No newline at end of file diff --git a/src/Endpoint.php b/src/Endpoint.php index f845f18..8099573 100644 --- a/src/Endpoint.php +++ b/src/Endpoint.php @@ -112,7 +112,7 @@ class Endpoint { { $card = $document->filter('.p-author.h-card')->eq(0); - if ($card) + if ($card->count()) { $name = $card->filter('.p-name')?->text(""); $url = $card->filter('.u-url')?->text(""); diff --git a/tests/EndpointTest.php b/tests/EndpointTest.php index b808c63..3f54359 100644 --- a/tests/EndpointTest.php +++ b/tests/EndpointTest.php @@ -119,9 +119,11 @@ class EndpointTest extends TestCase { -

Some content

-

Here's some body content. It contains a url.

-

I'm liking this post.

+
+

Some content

+

Here's some body content. It contains a url.

+

I'm liking this post.

+
XML; @@ -160,9 +162,11 @@ class EndpointTest extends TestCase { -

Some content

-

Here's some body content. It contains a url.

-

I'm writing about this post.

+
+

Some content

+

Here's some body content. It contains a url.

+

I'm writing about this post.

+
XML; @@ -200,9 +204,11 @@ class EndpointTest extends TestCase { -

Some content

-

Here's some body content. It contains a url.

-

I'm writing about this post.

+
+

Some content

+

Here's some body content. It contains a url.

+

I'm writing about this post.

+
XML; @@ -240,9 +246,11 @@ class EndpointTest extends TestCase { -

Some content

-

Here's some body content. It contains a url.

-

I'm writing about this post.

+ +

Some content

+

Here's some body content. It contains a url.

+

I'm writing about this post.

+ XML; @@ -265,7 +273,7 @@ class EndpointTest extends TestCase { $mockGateway->expects($this->once()) ->method('save') ->with($this->objectContains('type', MentionType::Repost)); - + $endpoint = new Endpoint($mockClient, $mockGateway); $endpoint->receiveWebmention($source, $target); }