Skip to content

Commit

Permalink
Revert "We no longer store times with dates, so update the tests to r…
Browse files Browse the repository at this point in the history
…eflect that."

This reverts commit b664921.
  • Loading branch information
duncanmcclean committed Mar 5, 2025
1 parent bd4e5f3 commit 1deebdd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions tests/Stache/FeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public function saving_an_entry_writes_it_to_file()
->data(['title' => 'Test Entry', 'foo' => 'bar'])
)->save();

$this->assertFileExists(__DIR__.'/__fixtures__/content/collections/blog/2017-07-04.test-entry.md');
$this->assertFileExists(__DIR__.'/__fixtures__/content/collections/blog/2017-07-04-0000.test-entry.md');

$entry->delete();
}
Expand All @@ -302,7 +302,7 @@ public function saving_an_entry_with_a_closure_based_slug_resolves_it_before_wri
->data(['title' => 'Test Entry', 'foo' => 'bar'])
)->save();

$this->assertFileExists(__DIR__.'/__fixtures__/content/collections/blog/2017-07-04.test-entry.md');
$this->assertFileExists(__DIR__.'/__fixtures__/content/collections/blog/2017-07-04-0000.test-entry.md');

$entry->delete();
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Stache/Repositories/EntryRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function it_saves_an_entry_to_the_stache_and_to_a_file()
->date('2017-07-04')
->data(['foo' => 'bar']);

$this->unlinkAfter($path = $this->directory.'/blog/2017-07-04.test.md');
$this->unlinkAfter($path = $this->directory.'/blog/2017-07-04-0000.test.md');

$this->assertCount(14, $this->repo->all());
$this->assertNull($this->repo->find('test-blog-entry'));
Expand All @@ -228,7 +228,7 @@ public function it_can_delete()
->date('2017-07-04')
->data(['foo' => 'bar']);

$this->unlinkAfter($path = $this->directory.'/blog/2017-07-04.test.md');
$this->unlinkAfter($path = $this->directory.'/blog/2017-07-04-0000.test.md');

$this->assertCount(14, $this->repo->all());
$this->assertNull($this->repo->find('test-blog-entry'));
Expand Down
34 changes: 17 additions & 17 deletions tests/Stache/Stores/EntriesStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public function it_gets_nested_files()
$files = Traverser::filter([$store, 'getItemFilter'])->traverse($store);

$this->assertEquals(collect([
$dir.'/blog/2017-25-12.christmas.md',
$dir.'/blog/2018-07-04.fourth-of-july.md',
$dir.'/blog/2017-25-12-0000.christmas.md',
$dir.'/blog/2018-07-04-0000.fourth-of-july.md',
])->sort()->values()->all(), $files->keys()->sort()->values()->all());
});

Expand Down Expand Up @@ -175,7 +175,7 @@ public function it_saves_to_disk()

$this->parent->store('blog')->save($entry);

$this->assertStringEqualsFile($path = $this->directory.'/blog/2017-07-04.test.md', $entry->fileContents());
$this->assertStringEqualsFile($path = $this->directory.'/blog/2017-07-04-0000.test.md', $entry->fileContents());
@unlink($path);
$this->assertFileDoesNotExist($path);

Expand All @@ -193,13 +193,13 @@ public function it_saves_to_disk_with_modified_path()

$this->parent->store('blog')->save($entry);

$this->assertStringEqualsFile($initialPath = $this->directory.'/blog/2017-07-04.test.md', $entry->fileContents());
$this->assertStringEqualsFile($initialPath = $this->directory.'/blog/2017-07-04-0000.test.md', $entry->fileContents());
$this->assertEquals($initialPath, $this->parent->store('blog')->paths()->get('123'));

$entry->slug('updated');
$entry->save();

$this->assertStringEqualsFile($path = $this->directory.'/blog/2017-07-04.updated.md', $entry->fileContents());
$this->assertStringEqualsFile($path = $this->directory.'/blog/2017-07-04-0000.updated.md', $entry->fileContents());
$this->assertEquals($path, $this->parent->store('blog')->paths()->get('123'));

@unlink($initialPath);
Expand All @@ -209,18 +209,18 @@ public function it_saves_to_disk_with_modified_path()
#[Test]
public function it_appends_suffix_to_the_filename_if_one_already_exists()
{
$existingPath = $this->directory.'/blog/2017-07-04.test.md';
$existingPath = $this->directory.'/blog/2017-07-04-0000.test.md';
file_put_contents($existingPath, $existingContents = "---\nid: existing-id\n---");

$entry = Facades\Entry::make()->id('new-id')->slug('test')->collection('blog')->date('2017-07-04');
$this->parent->store('blog')->save($entry);
$newPath = $this->directory.'/blog/2017-07-04.test.1.md';
$newPath = $this->directory.'/blog/2017-07-04-0000.test.1.md';
$this->assertStringEqualsFile($existingPath, $existingContents);
$this->assertStringEqualsFile($newPath, $entry->fileContents());

$anotherEntry = Facades\Entry::make()->id('another-new-id')->slug('test')->collection('blog')->date('2017-07-04');
$this->parent->store('blog')->save($anotherEntry);
$anotherNewPath = $this->directory.'/blog/2017-07-04.test.2.md';
$anotherNewPath = $this->directory.'/blog/2017-07-04-0000.test.2.md';
$this->assertStringEqualsFile($existingPath, $existingContents);
$this->assertStringEqualsFile($anotherNewPath, $anotherEntry->fileContents());

Expand All @@ -238,7 +238,7 @@ public function it_appends_suffix_to_the_filename_if_one_already_exists()
#[Test]
public function it_doesnt_append_the_suffix_to_the_filename_if_it_is_itself()
{
$existingPath = $this->directory.'/blog/2017-07-04.test.md';
$existingPath = $this->directory.'/blog/2017-07-04-0000.test.md';
file_put_contents($existingPath, "---\nid: the-id\n---");

$entry = Facades\Entry::make()
Expand All @@ -249,7 +249,7 @@ public function it_doesnt_append_the_suffix_to_the_filename_if_it_is_itself()

$this->parent->store('blog')->save($entry);

$pathWithSuffix = $this->directory.'/blog/2017-07-04.test.1.md';
$pathWithSuffix = $this->directory.'/blog/2017-07-04-0000.test.1.md';
$this->assertStringEqualsFile($existingPath, $entry->fileContents());
$this->assertEquals($existingPath, $this->parent->store('blog')->paths()->get('the-id'));

Expand All @@ -261,9 +261,9 @@ public function it_doesnt_append_the_suffix_to_the_filename_if_it_is_itself()
#[Test]
public function it_doesnt_append_the_suffix_to_an_already_suffixed_filename_if_it_is_itself()
{
$suffixlessExistingPath = $this->directory.'/blog/2017-07-04.test.md';
$suffixlessExistingPath = $this->directory.'/blog/2017-07-04-0000.test.md';
file_put_contents($suffixlessExistingPath, "---\nid: the-id\n---");
$suffixedExistingPath = $this->directory.'/blog/2017-07-04.test.md';
$suffixedExistingPath = $this->directory.'/blog/2017-07-04-0000.test.md';
file_put_contents($suffixedExistingPath, "---\nid: another-id\n---");

$entry = Facades\Entry::make()
Expand All @@ -274,7 +274,7 @@ public function it_doesnt_append_the_suffix_to_an_already_suffixed_filename_if_i

$this->parent->store('blog')->save($entry);

$pathWithIncrementedSuffix = $this->directory.'/blog/2017-07-04.test.2.md';
$pathWithIncrementedSuffix = $this->directory.'/blog/2017-07-04-0000.test.2.md';
$this->assertStringEqualsFile($suffixedExistingPath, $entry->fileContents());
@unlink($suffixedExistingPath);
$this->assertFileDoesNotExist($pathWithIncrementedSuffix);
Expand All @@ -286,8 +286,8 @@ public function it_doesnt_append_the_suffix_to_an_already_suffixed_filename_if_i
#[Test]
public function it_keeps_the_suffix_even_if_the_suffixless_path_is_available()
{
$existingPath = $this->directory.'/blog/2017-07-04.test.1.md';
$suffixlessPath = $this->directory.'/blog/2017-07-04.test.md';
$existingPath = $this->directory.'/blog/2017-07-04-0000.test.1.md';
$suffixlessPath = $this->directory.'/blog/2017-07-04-0000.test.md';

file_put_contents($existingPath, 'id: 123');
$entry = $this->parent->store('blog')->makeItemFromFile($existingPath, file_get_contents($existingPath));
Expand All @@ -309,8 +309,8 @@ public function it_removes_the_suffix_if_it_previously_had_one_but_needs_a_new_p
// eg. if the slug is changing, and the filename would be changing anyway,
// we shouldn't maintain the suffix.

$existingPath = $this->directory.'/blog/2017-07-04.test.1.md';
$newPath = $this->directory.'/blog/2017-07-04.updated.md';
$existingPath = $this->directory.'/blog/2017-07-04-0000.test.1.md';
$newPath = $this->directory.'/blog/2017-07-04-0000.updated.md';

file_put_contents($existingPath, 'id: 123');
$entry = $this->parent->store('blog')->makeItemFromFile($existingPath, file_get_contents($existingPath));
Expand Down

0 comments on commit 1deebdd

Please # to comment.