mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-23 21:43:17 +00:00
Update tests
This commit is contained in:
parent
f63f48beb6
commit
2598520bbe
7 changed files with 132 additions and 33 deletions
|
@ -8,13 +8,14 @@ use Illuminate\Foundation\Testing\WithoutMiddleware;
|
|||
|
||||
class InstalledTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function nodeinfo_api()
|
||||
{
|
||||
$response = $this->get('/.well-known/nodeinfo');
|
||||
$response->assertJson([
|
||||
'links' => [
|
||||
['rel' => 'http://nodeinfo.diaspora.software/ns/schema/2.0'],
|
||||
], ]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function nodeinfo_api()
|
||||
{
|
||||
$response = $this->get('/.well-known/nodeinfo');
|
||||
$response->assertJson([
|
||||
'links' => [
|
||||
['rel' => 'http://nodeinfo.diaspora.software/ns/schema/2.0'],
|
||||
], ]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,12 +9,11 @@ use App\User;
|
|||
|
||||
class LoginTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function view_login_page()
|
||||
{
|
||||
$response = $this->get('login');
|
||||
|
||||
/** @test */
|
||||
public function view_login_page()
|
||||
{
|
||||
$response = $this->get('login');
|
||||
|
||||
$response->assertSee('Forgot Password');
|
||||
}
|
||||
$response->assertSee('Forgot Password');
|
||||
}
|
||||
}
|
33
tests/Unit/DateTimeTest.php
Normal file
33
tests/Unit/DateTimeTest.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
class DateTimeTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function mastodonTimestamp()
|
||||
{
|
||||
$ts = Carbon::createFromFormat(\DateTime::ISO8601, '2019-09-16T02:41:57Z');
|
||||
$this->assertEquals(9, $ts->month);
|
||||
$this->assertEquals(16, $ts->day);
|
||||
$this->assertEquals(2019, $ts->year);
|
||||
$this->assertEquals(2, $ts->hour);
|
||||
$this->assertEquals(41, $ts->minute);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function p3kTimestamp()
|
||||
{
|
||||
$ts = Carbon::createFromFormat(\DateTime::ISO8601, '2019-09-16T08:40:55+10:00');
|
||||
$this->assertEquals(9, $ts->month);
|
||||
$this->assertEquals(16, $ts->day);
|
||||
$this->assertEquals(2019, $ts->year);
|
||||
$this->assertEquals(8, $ts->hour);
|
||||
$this->assertEquals(40, $ts->minute);
|
||||
}
|
||||
}
|
|
@ -6,13 +6,13 @@ use Tests\TestCase;
|
|||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBasicTest()
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBasicTest()
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,12 +9,13 @@ use App\Util\Lexer\RestrictedNames;
|
|||
|
||||
class RestrictedNameTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function restrictedUsername()
|
||||
{
|
||||
$this->assertContains('p', RestrictedNames::get());
|
||||
$this->assertContains('admin', RestrictedNames::get());
|
||||
$this->assertNotContains('dansup', RestrictedNames::get());
|
||||
$this->assertNotContains('lain', RestrictedNames::get());
|
||||
}
|
||||
/** @test */
|
||||
public function restrictedUsername()
|
||||
{
|
||||
$names = RestrictedNames::get();
|
||||
$this->assertContains('p', $names);
|
||||
$this->assertContains('admin', $names);
|
||||
$this->assertNotContains('dansup', $names);
|
||||
$this->assertNotContains('earth', $names);
|
||||
}
|
||||
}
|
||||
|
|
17
tests/Unit/SnowflakeTest.php
Normal file
17
tests/Unit/SnowflakeTest.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use Tests\TestCase;
|
||||
use App\Services\SnowflakeService;
|
||||
|
||||
class Snowflake extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function snowflakeTest()
|
||||
{
|
||||
$expected = 266077397319815168;
|
||||
$actual = SnowflakeService::byDate(now()->parse('2021-02-13T05:36:35+00:00'));
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
48
tests/Unit/WebfingerTest.php
Normal file
48
tests/Unit/WebfingerTest.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use Tests\TestCase;
|
||||
use App\Util\Lexer\Nickname;
|
||||
|
||||
class WebfingerTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function webfingerTest()
|
||||
{
|
||||
$expected = [
|
||||
"domain" => "pixelfed.org",
|
||||
"username" => "dansup",
|
||||
];
|
||||
$actual = Nickname::normalizeProfileUrl('acct:dansup@pixelfed.org');
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$expected = [
|
||||
"domain" => "pixelfed.org",
|
||||
"username" => "dansup_",
|
||||
];
|
||||
$actual = Nickname::normalizeProfileUrl('acct:dansup@pixelfed.org');
|
||||
$this->assertNotEquals($expected, $actual);
|
||||
|
||||
$expected = [
|
||||
"domain" => "pixelfed.org",
|
||||
"username" => "dansup",
|
||||
];
|
||||
$actual = Nickname::normalizeProfileUrl('acct:@dansup@pixelfed.org');
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$expected = [
|
||||
"domain" => "pixelfed.org",
|
||||
"username" => "dansup",
|
||||
];
|
||||
$actual = Nickname::normalizeProfileUrl('dansup@pixelfed.org');
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$expected = [
|
||||
"domain" => "pixelfed.org",
|
||||
"username" => "dansup",
|
||||
];
|
||||
$actual = Nickname::normalizeProfileUrl('@dansup@pixelfed.org');
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue