Skip to content

Commit

Permalink
[#13518] - Re-enabled commented out tests
Browse files Browse the repository at this point in the history
  • Loading branch information
niden committed Dec 25, 2019
1 parent 3773c95 commit 1314654
Showing 1 changed file with 161 additions and 161 deletions.
322 changes: 161 additions & 161 deletions tests/integration/Mvc/Model/UnderscoreGetCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,167 +37,167 @@ public function _after(IntegrationTester $I)
$this->container['db']->close();
}

// /**
// * Tests Phalcon\Mvc\Model :: __get()
// *
// * @author Balázs Németh <https://github.com/zsilbi>
// * @since 2019-05-07
// */
// public function mvcModelUnderscoreGet(IntegrationTester $I)
// {
// $I->wantToTest('Mvc\Model - __get()');
//
// $user = new Models\Users();
//
// $user->id = 999;
// $user->name = 'Test';
//
// $I->assertEquals(
// 999,
// $user->id
// );
//
// $I->assertEquals(
// 'Test',
// $user->name
// );
// }
//
// /**
// * Tests Phalcon\Mvc\Model :: __get() whether it is using getters correctly
// *
// * @author Balázs Németh <https://github.com/zsilbi>
// * @since 2019-05-07
// */
// public function mvcModelUnderscoreGetIsUsingGetters(IntegrationTester $I)
// {
// $I->wantToTest("Mvc\Model - __get() whether it is using getters correctly");
//
// $model = new Models\Select();
// $model->setId(123);
//
// $I->assertEquals(
// 123,
// $model->id
// );
//
// $associativeArray = [
// 'firstName' => 'First name',
// 'lastName' => 'Last name',
// ];
//
// $model->setName($associativeArray);
//
// $I->assertEquals(
// $associativeArray,
// $model->name
// );
//
// $model->setText('MyText');
//
// $I->assertEquals(
// 'MyText',
// $model->text
// );
// }
//
// /**
// * Tests Phalcon\Mvc\Model :: __get() related records
// *
// * @author Balázs Németh <https://github.com/zsilbi>
// * @since 2019-05-07
// */
// public function mvcModelUnderscoreGetRelated(IntegrationTester $I)
// {
// $I->wantToTest('Mvc\Model - __get() related records');
//
// /**
// * Belongs-to relationship
// */
// $robotPart = Models\RobotsParts::findFirst();
//
// $part = $robotPart->part;
//
// $I->assertInstanceOf(
// Models\Parts::class,
// $part
// );
//
// /**
// * Testing has-one relationship
// */
// $customer = Models\Customers::findFirst();
//
// $user = $customer->user;
//
// $I->assertInstanceOf(
// Models\Users::class,
// $user
// );
//
// /**
// * Has-many relationship
// */
// $robot = Models\Robots::findFirst();
//
// $robotParts = $robot->robotsParts;
//
// $I->assertInstanceOf(
// Simple::class,
// $robotParts
// );
// }
//
// /**
// * Tests Phalcon\Mvc\Model :: __get() dirty related records
// *
// * @author Balázs Németh <https://github.com/zsilbi>
// * @since 2019-05-07
// */
// public function mvcModelUnderscoreGetDirtyRelated(IntegrationTester $I)
// {
// $I->wantToTest('Mvc\Model - __get() dirty related records');
//
// $robot = Models\Robots::findFirst();
//
// /**
// * Fill up the related cache with data
// */
// $robotsParts = $robot->robotsParts;
//
// $I->assertInstanceOf(
// Simple::class,
// $robotsParts
// );
//
// /**
// * Add new related records
// */
// $robot->robotsParts = [
// new Models\RobotsParts(),
// new Models\RobotsParts(),
// ];
//
// /**
// * Test if the new records were returned
// */
// $dirtyRobotsParts = $robot->robotsParts;
//
// $I->assertInternalType(
// 'array',
// $dirtyRobotsParts
// );
//
// $I->assertCount(
// 2,
// $dirtyRobotsParts
// );
//
// $I->assertInstanceOf(
// Models\RobotsParts::class,
// $dirtyRobotsParts[0]
// );
// }
/**
* Tests Phalcon\Mvc\Model :: __get()
*
* @author Balázs Németh <https://github.com/zsilbi>
* @since 2019-05-07
*/
public function mvcModelUnderscoreGet(IntegrationTester $I)
{
$I->wantToTest('Mvc\Model - __get()');

$user = new Models\Users();

$user->id = 999;
$user->name = 'Test';

$I->assertEquals(
999,
$user->id
);

$I->assertEquals(
'Test',
$user->name
);
}

/**
* Tests Phalcon\Mvc\Model :: __get() whether it is using getters correctly
*
* @author Balázs Németh <https://github.com/zsilbi>
* @since 2019-05-07
*/
public function mvcModelUnderscoreGetIsUsingGetters(IntegrationTester $I)
{
$I->wantToTest("Mvc\Model - __get() whether it is using getters correctly");

$model = new Models\Select();
$model->setId(123);

$I->assertEquals(
123,
$model->id
);

$associativeArray = [
'firstName' => 'First name',
'lastName' => 'Last name',
];

$model->setName($associativeArray);

$I->assertEquals(
$associativeArray,
$model->name
);

$model->setText('MyText');

$I->assertEquals(
'MyText',
$model->text
);
}

/**
* Tests Phalcon\Mvc\Model :: __get() related records
*
* @author Balázs Németh <https://github.com/zsilbi>
* @since 2019-05-07
*/
public function mvcModelUnderscoreGetRelated(IntegrationTester $I)
{
$I->wantToTest('Mvc\Model - __get() related records');

/**
* Belongs-to relationship
*/
$robotPart = Models\RobotsParts::findFirst();

$part = $robotPart->part;

$I->assertInstanceOf(
Models\Parts::class,
$part
);

/**
* Testing has-one relationship
*/
$customer = Models\Customers::findFirst();

$user = $customer->user;

$I->assertInstanceOf(
Models\Users::class,
$user
);

/**
* Has-many relationship
*/
$robot = Models\Robots::findFirst();

$robotParts = $robot->robotsParts;

$I->assertInstanceOf(
Simple::class,
$robotParts
);
}

/**
* Tests Phalcon\Mvc\Model :: __get() dirty related records
*
* @author Balázs Németh <https://github.com/zsilbi>
* @since 2019-05-07
*/
public function mvcModelUnderscoreGetDirtyRelated(IntegrationTester $I)
{
$I->wantToTest('Mvc\Model - __get() dirty related records');

$robot = Models\Robots::findFirst();

/**
* Fill up the related cache with data
*/
$robotsParts = $robot->robotsParts;

$I->assertInstanceOf(
Simple::class,
$robotsParts
);

/**
* Add new related records
*/
$robot->robotsParts = [
new Models\RobotsParts(),
new Models\RobotsParts(),
];

/**
* Test if the new records were returned
*/
$dirtyRobotsParts = $robot->robotsParts;

$I->assertInternalType(
'array',
$dirtyRobotsParts
);

$I->assertCount(
2,
$dirtyRobotsParts
);

$I->assertInstanceOf(
Models\RobotsParts::class,
$dirtyRobotsParts[0]
);
}

/**
* Tests Phalcon\Mvc\Model :: __get() private property
Expand Down

0 comments on commit 1314654

Please sign in to comment.