Skip to content
Permalink
Browse files

Clean up tests a bit.

Use less code to get things done.
  • Loading branch information...
markstory committed May 16, 2015
1 parent 95a0fb6 commit 6a8aaade570b5101479975080dc494bac5a3b7d0
Showing with 12 additions and 19 deletions.
  1. +12 −19 tests/TestCase/ORM/MarshallerTest.php
@@ -721,16 +721,10 @@ public function testBelongsToManyWithMixedData()
]
];
$articles = TableRegistry::get('Articles');
$articles->belongsToMany('Tags');
$tags = TableRegistry::get('Tags');
$article = $articles->newEntity($data, [
'associated' => [
'Tags'
]
]);
$marshaller = new Marshaller($this->articles);
$article = $marshaller->one($data, ['associated' => ['Tags']]);
$this->assertEquals($data['tags'][0]['name'], $article->tags[0]->name);
$this->assertEquals($data['tags'][1]['name'], $article->tags[1]->name);
@@ -741,7 +735,7 @@ public function testBelongsToManyWithMixedData()
$this->assertEquals($article->tags[2]->isNew(), false);
$tagCount = $tags->find()->count();
$articles->save($article);
$this->articles->save($article);
$this->assertEquals($tagCount + 2, $tags->find()->count());
}
@@ -754,20 +748,18 @@ public function testBelongsToManyWithMixedData()
public function testHasManyWithIds()
{
$data = [
'username' => 'lux',
'password' => 'passphrase',
'title' => 'article',
'body' => 'some content',
'comments' => [
'_ids' => [1, 2]
]
];
$userTable = TableRegistry::get('Users');
$userTable->hasMany('Comments');
$commentTable = TableRegistry::get('Comments');
$user = $userTable->newEntity($data, ['associated' => ['Comments']]);
$marshaller = new Marshaller($this->articles);
$article = $marshaller->one($data, ['associated' => ['Comments']]);
$this->assertEquals($user->comments[0], $commentTable->get(1));
$this->assertEquals($user->comments[1], $commentTable->get(2));
$this->assertEquals($article->comments[0], $this->comments->get(1));
$this->assertEquals($article->comments[1], $this->comments->get(2));
}
/**
@@ -785,11 +777,12 @@ public function testHasManyInvalidData()
]
];
$article = $this->articles->newEntity($data, ['associated' => ['Comments']]);
$marshaller = new Marshaller($this->articles);
$article = $marshaller->one($data, ['associated' => ['Comments']]);
$this->assertEmpty($article->comments);
$data['comments'] = 1;
$article = $this->articles->newEntity($data, ['associated' => ['Comments']]);
$article = $marshaller->one($data, ['associated' => ['Comments']]);
$this->assertEmpty($article->comments);
}

0 comments on commit 6a8aaad

Please sign in to comment.
You can’t perform that action at this time.