Skip to content

Commit

Permalink
[#13002] - Changing the test model
Browse files Browse the repository at this point in the history
  • Loading branch information
niden committed May 15, 2019
1 parent b4119fd commit f5fe2a9
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions tests/integration/Mvc/Model/SaveCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@

use IntegrationTester;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use Phalcon\Test\Models;
use Phalcon\Mvc\Model;
use Phalcon\Test\Models\AlbumORama\Artists;
use Phalcon\Test\Models\Robots;
use function is_int;
use function is_string;
use Phalcon\Test\Models\Users;
use function uniqid;

/**
* Class SaveCest
Expand Down Expand Up @@ -263,30 +267,26 @@ public function mvcModelSaveCastLastInsertId(IntegrationTester $I, Example $func
$method = $function[0];
$this->$method();

Robots::setup(
Artists::setup(
[
'castLastInsertIdToInt' => true,
]
);

$name = uniqid();
$robot = new Robots();
$robot->name = $name;
$robot->type = 'Mechanical';
$robot->year = 2019;
$robot->datetime = '2019-05-10 00:00:00';
$robot->text = 'Some Text';
$name = uniqid();
$user = new Users();
$user->name = $name;

$result = $robot->save();
$result = $user->save();
$I->assertTrue($result);

$actual = $robot->id;
$actual = $user->id;
$I->assertTrue(is_int($actual));

$expected = intval($actual, 10);
$I->assertEquals($expected, $actual);

$result = $robot->delete();
$result = $user->delete();
$I->assertTrue($result);

Robots::setup(
Expand All @@ -295,24 +295,20 @@ public function mvcModelSaveCastLastInsertId(IntegrationTester $I, Example $func
]
);

$name = uniqid();
$robot = new Robots();
$robot->name = $name;
$robot->type = 'mechanical';
$robot->year = 2019;
$robot->datetime = '2019-05-10 00:00:00';
$robot->text = 'Some Text';
$name = uniqid();
$user = new Users();
$user->name = $name;

$result = $robot->save();
$result = $user->save();
$I->assertTrue($result);

$actual = $robot->id;
$actual = $user->id;
$I->assertTrue(is_string($actual));

$expected = (string) $actual;
$I->assertEquals($expected, $actual);

$result = $robot->delete();
$result = $user->delete();
$I->assertTrue($result);
}

Expand Down

0 comments on commit f5fe2a9

Please sign in to comment.