From 3206771918964c1c9cd4095fd03ac0baf00b6fbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=82=E6=B5=81?= Date: Thu, 14 Nov 2024 18:08:23 +0800 Subject: [PATCH] Add initial test for sentence count update --- tests/TestCase/Model/Table/VocabularyTableTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/TestCase/Model/Table/VocabularyTableTest.php b/tests/TestCase/Model/Table/VocabularyTableTest.php index 1d6d5b5755..473f1a9186 100644 --- a/tests/TestCase/Model/Table/VocabularyTableTest.php +++ b/tests/TestCase/Model/Table/VocabularyTableTest.php @@ -9,6 +9,8 @@ class VocabularyTableTest extends TestCase { + use \App\Test\TestCase\SearchMockTrait; + public $fixtures = [ 'app.vocabulary', 'app.users_vocabulary', @@ -44,6 +46,16 @@ public function testAddItem_withNewVocabulary() $this->assertEquals(2, $result->id); } + public function testAddItem_updatesCurrentNumberOfSentences() + { + $this->enableMockedSearch([21, 11, 12], 4); + CurrentUser::store(['id' => 7]); + + $result = $this->Vocabulary->addItem('eng', 'hashtag'); + + $this->assertEquals(4, $result->numSentences); + } + public function testIncrementNumSentences_succeeds() { $result = $this->Vocabulary->incrementNumSentences(1, 'This happened out of the blue.');