From 961d780ed00bfabd36c96f5e4a35d96611be9707 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Wed, 3 Apr 2013 17:55:48 +0200 Subject: [PATCH] remove trailing .txt when getting the note --- businesslayer/notesbusinesslayer.php | 2 +- db/note.php | 2 +- tests/db/NoteTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/businesslayer/notesbusinesslayer.php b/businesslayer/notesbusinesslayer.php index 47f636fc..eecb2ff6 100644 --- a/businesslayer/notesbusinesslayer.php +++ b/businesslayer/notesbusinesslayer.php @@ -44,7 +44,7 @@ class NotesBusinessLayer { $note = new Note(); $note->fromFile(array( - 'name' => $title, + 'name' => $title . '.txt', 'content' => $this->fileSystem->file_get_contents('/' . $title . '.txt'), 'mtime' => $this->fileSystem->filemtime('/' . $title . '.txt') )); diff --git a/db/note.php b/db/note.php index 3afbf80c..ece3c339 100644 --- a/db/note.php +++ b/db/note.php @@ -16,7 +16,7 @@ class Note { public function fromFile($file){ $this->modified = (int) $file['mtime']; - $this->title = $file['name']; + $this->title = substr($file['name'], 0, -4); // remove trailing .txt $this->content = $file['content']; } diff --git a/tests/db/NoteTest.php b/tests/db/NoteTest.php index 940eb8f8..6a5c2223 100644 --- a/tests/db/NoteTest.php +++ b/tests/db/NoteTest.php @@ -30,7 +30,7 @@ class NoteTest extends TestUtility { $note->fromFile($file); $this->assertEquals($file['mtime'], $note->getModified()); - $this->assertEquals($file['name'], $note->getTitle()); + $this->assertEquals('hi', $note->getTitle()); $this->assertEquals($file['content'], $note->getContent()); }