Skip to content

Commit

Permalink
Merge pull request #8 from sizuhiko/develop
Browse files Browse the repository at this point in the history
For Release v0.2.1
  • Loading branch information
sizuhiko committed Aug 14, 2015
2 parents c6e06bd + 793579b commit ed1f8d4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/Adaptor/CakeFabricateAdaptor.php
Expand Up @@ -102,7 +102,10 @@ public function getModel($modelName)
public function create($modelName, $attributes, $recordCount)
{
$table = TableRegistry::get($modelName);
$entities = $table->newEntities($attributes, ['validate' => $this->options[self::OPTION_VALIDATE], 'accessibleFields' => ['*' => true]]);
$entities = $table->newEntities($attributes, [
'validate' => $this->options[self::OPTION_VALIDATE],
'accessibleFields' => ['*' => true]
]);
$table->connection()->transactional(function () use ($table, $entities) {
foreach ($entities as $entity) {
$ret = $table->save($entity, [
Expand All @@ -124,7 +127,10 @@ public function create($modelName, $attributes, $recordCount)
public function build($modelName, $data)
{
$table = TableRegistry::get($modelName);
$entity = $table->newEntity($data, ['validate' => $this->options[self::OPTION_VALIDATE]]);
$entity = $table->newEntity($data, [
'validate' => $this->options[self::OPTION_VALIDATE],
'accessibleFields' => ['*' => true]
]);
return $entity;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/CakeFabricateTest.php
Expand Up @@ -29,7 +29,7 @@ public function testAttributesFor() {
return ["created" => "2013-10-09 12:40:28", "updated" => "2013-10-09 12:40:28"];
});
$this->assertCount(10, $results);
for ($i = 0; $i < 10; $i++) {
for ($i = 0; $i < 10; $i++) {
$this->assertEquals($i+1, $results[$i]['id']);
$this->assertEquals($i+1, $results[$i]['author_id']);
$this->assertEquals(50, strlen($results[$i]['title']));
Expand Down
7 changes: 7 additions & 0 deletions tests/test_app/Model/Entity/Post.php
Expand Up @@ -8,4 +8,11 @@
*/
class Post extends Entity
{
protected $_accessible = [
'title' => true,
'body' => true,
'published' => true,
'created' => true,
'updated' => true
];
}

0 comments on commit ed1f8d4

Please sign in to comment.