diff --git a/tests/TestCase/Model/Behavior/UploadBehaviorTest.php b/tests/TestCase/Model/Behavior/UploadBehaviorTest.php index b8a4969..14b4845 100644 --- a/tests/TestCase/Model/Behavior/UploadBehaviorTest.php +++ b/tests/TestCase/Model/Behavior/UploadBehaviorTest.php @@ -68,10 +68,14 @@ public function testInitialize() { $table = $this->getMockBuilder('Cake\ORM\Table')->getMock(); $schema = $this->getMockBuilder('Cake\Database\Schema\TableSchema') - ->onlyMethods(['setColumnType']) + ->onlyMethods(['setColumnType', 'hasColumn']) ->disableOriginalConstructor() ->getMock(); - $schema->expects($this->any()) + $schema->expects($this->once()) + ->method('hasColumn') + ->with('field') + ->willReturn(true); + $schema->expects($this->once()) ->method('setColumnType') ->with('field', 'upload.file'); $table->expects($this->any()) @@ -110,10 +114,14 @@ public function testInitializeIndexedConfig() $settings = ['field']; $table = $this->getMockBuilder('Cake\ORM\Table')->getMock(); $schema = $this->getMockBuilder('Cake\Database\Schema\TableSchema') - ->onlyMethods(['setColumnType']) + ->onlyMethods(['setColumnType', 'hasColumn']) ->disableOriginalConstructor() ->getMock(); - $schema->expects($this->any()) + $schema->expects($this->once()) + ->method('hasColumn') + ->with('field') + ->willReturn(true); + $schema->expects($this->once()) ->method('setColumnType') ->with('field', 'upload.file'); $table->expects($this->any()) @@ -142,10 +150,14 @@ public function testInitializeAddBehaviorOptionsInterfaceConfig() ]; $table = $this->getMockBuilder('Cake\ORM\Table')->getMock(); $schema = $this->getMockBuilder('Cake\Database\Schema\TableSchema') - ->onlyMethods(['setColumnType']) + ->onlyMethods(['setColumnType', 'hasColumn']) ->disableOriginalConstructor() ->getMock(); - $schema->expects($this->any()) + $schema->expects($this->once()) + ->method('hasColumn') + ->with('field') + ->willReturn(true); + $schema->expects($this->once()) ->method('setColumnType') ->with('field', 'upload.file'); $table->expects($this->any()) diff --git a/tests/schema.php b/tests/schema.php index 37da7c8..9eca1f5 100644 --- a/tests/schema.php +++ b/tests/schema.php @@ -7,6 +7,7 @@ 'columns' => [ 'id' => ['type' => 'integer'], 'filename' => ['type' => 'string'], + 'field' => ['type' => 'string'], 'created' => ['type' => 'datetime', 'null' => true], ], 'constraints' => [