/** * @coversNothing */ public function testComplexFindAll() { $users = User::findAll()->where('name', 'User 1')->whereNot('addressId', null)->limit(2)->order('isBlocked', 'DESC')->joinAliased('Address', 'adr', ['addressId' => 'adr.id'])->having('password', null)->group('User.id')->column(new SQL('CONCAT(name, "test")'), 'param')->prependColumn(new SQL('COUNT(addressId)'), 'param2')->load(); $user = $users->getFirst(); $obj = new SaveableObject(); $obj->setVar('test1'); $userProps = ['id' => 1, 'name' => 'User 1', 'password' => null, 'addressId' => 1, 'isBlocked' => 0, 'deletedAt' => null, 'locationId' => 1, 'locationClass' => 'Harp\\Harp\\Test\\TestModel\\City', 'test' => null, 'object' => $obj, 'parentId' => null]; $this->assertEquals($userProps, $user->getProperties()); $userUnmapped = ['param2' => 1, 'param' => 'User 1test']; $this->assertSame($userUnmapped, $user->getUnmapped()); $this->assertQueries(['SELECT COUNT(addressId) AS `param2`, `User`.*, CONCAT(name, "test") AS `param` FROM `User` JOIN `Address` AS `adr` ON `addressId` = `adr`.`id` WHERE (`name` = "User 1") AND (`addressId` IS NOT NULL) AND (`User`.`deletedAt` IS NULL) GROUP BY `User`.`id` HAVING (`password` IS NULL) ORDER BY `isBlocked` DESC LIMIT 2']); }
/** * @covers ::initializeModel */ public function testInitializeModel() { $user = new User(); $user->object = 'C:41:"Harp\\Harp\\Test\\Integration\\SaveableObject":22:{a:1:{i:0;s:5:"test1";}}'; $expected = new SaveableObject(); $expected->setVar('test1'); User::getRepo()->initializeModel($user); $this->assertEquals($expected, $user->object); $post = new BlogPost(['class' => null]); BlogPost::getRepo()->initializeModel($post); $this->assertEquals('Harp\\Harp\\Test\\TestModel\\BlogPost', $post->class); }