Skip to content

Commit

Permalink
Added field column, mocked hasColumn
Browse files Browse the repository at this point in the history
  • Loading branch information
MolbioUnige committed Sep 19, 2024
1 parent 49f237d commit d2d6367
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
24 changes: 18 additions & 6 deletions tests/TestCase/Model/Behavior/UploadBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down
1 change: 1 addition & 0 deletions tests/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'columns' => [
'id' => ['type' => 'integer'],
'filename' => ['type' => 'string'],
'field' => ['type' => 'string'],
'created' => ['type' => 'datetime', 'null' => true],
],
'constraints' => [
Expand Down

0 comments on commit d2d6367

Please sign in to comment.