diff options
| author | Gerardo Zamudio <gerardozamudio@users.noreply.github.com> | 2016-02-24 23:48:50 -0600 |
|---|---|---|
| committer | Gerardo Zamudio <gerardozamudio@users.noreply.github.com> | 2016-02-24 23:48:50 -0600 |
| commit | e4de6b3898b64b26d29aff31f21df5fda8055686 (patch) | |
| tree | 575f8a65440f291d70a070d168eafca8c82a6459 /tests/units/Model/LastLoginTest.php | |
| parent | d9ffbea174ea6524d0a22f8375ca8b3aa04a3c96 (diff) | |
| parent | a6540bc604c837d92c9368540c145606723e97f7 (diff) | |
Merge pull request #1 from fguillot/master
Update from upstream
Diffstat (limited to 'tests/units/Model/LastLoginTest.php')
| -rw-r--r-- | tests/units/Model/LastLoginTest.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/units/Model/LastLoginTest.php b/tests/units/Model/LastLoginTest.php new file mode 100644 index 00000000..fc5ea1e5 --- /dev/null +++ b/tests/units/Model/LastLoginTest.php @@ -0,0 +1,43 @@ +<?php + +require_once __DIR__.'/../Base.php'; + +use Kanboard\Model\LastLogin; + +class LastLoginTest extends Base +{ + public function testCreate() + { + $lastLoginModel = new LastLogin($this->container); + + $this->assertTrue($lastLoginModel->create('Test1', 1, '127.0.0.1', 'My browser')); + $this->assertTrue($lastLoginModel->create('Test2', 1, '127.0.0.1', str_repeat('Too long', 50))); + $this->assertTrue($lastLoginModel->create('Test3', 1, '2001:0db8:0000:0000:0000:ff00:0042:8329', 'My Ipv6 browser')); + + $connections = $lastLoginModel->getAll(1); + $this->assertCount(3, $connections); + + $this->assertEquals('Test3', $connections[0]['auth_type']); + $this->assertEquals('2001:0db8:0000:0000:0000:ff00:0042:8329', $connections[0]['ip']); + + $this->assertEquals('Test2', $connections[1]['auth_type']); + $this->assertEquals('127.0.0.1', $connections[1]['ip']); + + $this->assertEquals('Test1', $connections[2]['auth_type']); + $this->assertEquals('127.0.0.1', $connections[2]['ip']); + } + + public function testCleanup() + { + $lastLoginModel = new LastLogin($this->container); + + for ($i = 0; $i < $lastLoginModel::NB_LOGINS + 5; $i++) { + $this->assertTrue($lastLoginModel->create('Test' . $i, 1, '127.0.0.1', 'My browser')); + } + + $connections = $lastLoginModel->getAll(1); + $this->assertCount(10, $connections); + $this->assertEquals('Test14', $connections[0]['auth_type']); + $this->assertEquals('Test5', $connections[9]['auth_type']); + } +} |
