コード例 #1
0
 /**
  * Test that save() ignores non entity values.
  *
  * @return void
  */
 public function testSaveOnlyEntities()
 {
     $connection = ConnectionManager::get('test');
     $mock = $this->getMock('Cake\\ORM\\Table', ['save', 'schema'], [['table' => 'tags', 'connection' => $connection]]);
     $mock->primaryKey('id');
     $config = ['sourceTable' => $this->article, 'targetTable' => $mock, 'saveStrategy' => BelongsToMany::SAVE_APPEND];
     $entity = new Entity(['id' => 1, 'title' => 'First Post', 'tags' => [['tag' => 'nope'], new Entity(['tag' => 'cakephp'])]]);
     $mock->expects($this->never())->method('save');
     $association = new BelongsToMany('Tags', $config);
     $association->save($entity);
 }