浏览代码

Add test for overwrite and no title present.

mscherer 1 年之前
父节点
当前提交
48bfcb9889
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      tests/TestCase/Model/Behavior/SluggedBehaviorTest.php

+ 9 - 0
tests/TestCase/Model/Behavior/SluggedBehaviorTest.php

@@ -217,6 +217,15 @@ class SluggedBehaviorTest extends TestCase {
 
 		$result = $this->articles->save($entity);
 		$this->assertEquals('Some-really-other-title', $result->get('slug'));
+
+		$this->articles->behaviors()->Slugged->setConfig(['overwrite' => true]);
+		// Without title present it should not modify the slug
+		$entity = $this->articles->patchEntity($entity, ['foo' => 'bar']);
+		$result = $this->articles->needsSlugUpdate($entity);
+		$this->assertFalse($result);
+
+		$result = $this->articles->save($entity);
+		$this->assertEquals('Some-really-other-title', $result->get('slug'));
 	}
 
 	/**