12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace Tests\Unit;
- use App\Post;
- use Carbon\Carbon;
- use Tests\TestCase;
- use Illuminate\Foundation\Testing\DatabaseMigrations;
- use Illuminate\Foundation\Testing\DatabaseTransactions;
- class ExampleTest extends TestCase
- {
- use DatabaseTransactions;
-
- public function testBasicTest()
- {
-
-
-
-
- $firstPost = factory(Post::class)->create();
- $secondPost = factory(Post::class)->create([
- 'created_at' => Carbon::now()->subMonth(),
- ]);
-
- $posts = Post::archives();
-
- $this->assertCount(2, $posts);
- $this->assertSame([
- [
- 'year' => (int) $firstPost->created_at->format('Y'),
- 'month' => $firstPost->created_at->format('F'),
- 'published' => 1,
- ],
- [
- 'year' => (int) $secondPost->created_at->format('Y'),
- 'month' => $secondPost->created_at->format('F'),
- 'published' => 1,
- ],
- ], $posts);
- }
- }
|