All Data Structures Namespaces Files Functions Variables Pages
UserTest Class Reference
Inheritance diagram for UserTest:

## Public Member Functions

| testUserPassword ()
| testSave ()

## Detailed Description

Definition at line 3 of file UserTest.php.

## Member Function Documentation

testSave | ( |  | ) |

Definition at line 27 of file UserTest.php.

{
list($server, $mysqlConfig) = require("test/config.php");
$dbh = new PDO($mysqlConfig[4][0], $mysqlConfig[1], $mysqlConfig[2]);
$dbh->exec("DROP DATABASE ".$mysqlConfig[4][1]);
$dbh->exec("CREATE DATABASE ".$mysqlConfig[4][1]);
\Entity\ModelBase::init($mysqlConfig);
$context = new \Tools\Context($server, false);
\Entity\ModelBase::setup();
$user = new \Entity\User();
$today = new \DateTime();
$today = $today->format("Y-m-d");
$this->assertEquals($today, $user->register);
$this->assertEquals($today, $user->lastVisit);
$this->assertEquals($today, $user->lastConnect);
$this->assertEquals($server["REMOTE_ADDR"], $user->registerIp);
$this->assertEquals($server["REMOTE_ADDR"], $user->lastVisitIp);
$this->assertEquals($server["REMOTE_ADDR"], $user->lastConnectIp);
$user->setPassword("test");
$user->email = "testUser@testhostname.dev";
$user->sexe = "MALE";
$user->optin = true;
$this->assertNull($user->id);
$user->save();
$this->assertNotNull($user->id);
$this->assertInternalType('int', $user->id);
$this->assertEquals(1, $user->id);
$user = new \Entity\User();
$user->setPassword("test");
$user->email = "testUser2@testhostname.dev";
$user->sexe = "FEMALE";
$user->optin = false;
$this->assertNull($user->id);
$user->save();
$this->assertNotNull($user->id);
$this->assertInternalType('int', $user->id);
$this->assertEquals(2, $user->id);
$user1 = new \Entity\User(1);
$user2 = new \Entity\User(2);
$today = new \DateTime();
$today->setTime(0, 0, 0);
$today = $today->format("Y-m-d H:i:s");
$this->assertEquals($today, $user1->register);
$this->assertEquals($today, $user1->lastVisit);
$this->assertEquals($today, $user1->lastConnect);
$this->assertEquals($server["REMOTE_ADDR"], $user1->registerIp);
$this->assertEquals($server["REMOTE_ADDR"], $user1->lastVisitIp);
$this->assertEquals($server["REMOTE_ADDR"], $user1->lastConnectIp);
$this->assertEquals("testUser@testhostname.dev", $user1->email);
$this->assertEquals("testUser2@testhostname.dev", $user2->email);
$this->assertEquals("MALE", $user1->sexe);
$this->assertEquals("FEMALE", $user2->sexe);
$this->assertTrue($user1->optin == 1);
$this->assertFalse($user2->optin == 1);
$this->assertNotNull($user1->id);
$this->assertInternalType('int', $user1->id);
$this->assertEquals(1, $user1->id);
$this->assertNotNull($user2->id);
$this->assertInternalType('int', $user2->id);
$this->assertEquals(2, $user2->id);
$user1->sexe = "FEMALE";
$user1->save();
$user3 = new \Entity\User(1);
$this->assertEquals("testUser@testhostname.dev", $user3->email);
$this->assertEquals("FEMALE", $user3->sexe);
$this->assertTrue($user3->optin == 1);
$this->assertNotNull($user3->id);
$this->assertInternalType('int', $user3->id);
$this->assertEquals(1, $user3->id);
}
Entity\ModelBase\init
static init($config=null)
Definition: ModelBase.php:23
Entity\ModelBase\setup
static setup()
Definition: ModelBase.php:53
$context
$context
Definition: index.php:6

testUserPassword | ( |  | ) |

Definition at line 5 of file UserTest.php.

{
list($server, $mysqlConfig) = require("test/config.php");
$dbh = new PDO($mysqlConfig[4][0], $mysqlConfig[1], $mysqlConfig[2]);
$dbh->exec("CREATE DATABASE ".$mysqlConfig[4][1]);
\Entity\ModelBase::init($mysqlConfig);
$context = new \Tools\Context($server, false);
\Entity\ModelBase::setup();
$user = new \Entity\User();
$user->setPassword("test");
$this->assertTrue($user->checkPassword("test"));
$this->assertFalse($user->checkPassword("test2"));
$this->assertEquals(60, strlen($user->password));
$this->assertNotEquals("test", $user->password);
$user->password = "test2";
$this->assertFalse($user->checkPassword("test"));
$this->assertTrue($user->checkPassword("test2"));
$this->assertEquals(60, strlen($user->password));
$this->assertNotEquals("test2", $user->password);
}
Entity\ModelBase\init
static init($config=null)
Definition: ModelBase.php:23
Entity\ModelBase\setup
static setup()
Definition: ModelBase.php:53
$context
$context
Definition: index.php:6

The documentation for this class was generated from the following file:

- /home/isundil/Project/ecom/test/models/UserTest.php