diff --git a/library/Class/LeKioskLink.php b/library/Class/LeKioskLink.php index 04b9df9cb26737b08df1d893b15eee404b298e29..1789d73bb1983f54835852eb7c7777cc135a7ddd 100644 --- a/library/Class/LeKioskLink.php +++ b/library/Class/LeKioskLink.php @@ -36,7 +36,7 @@ class Class_LeKioskLink { public function __construct($mail) { - $this->_mail = $mail; + $this->_mail = ($mail) ? $mail : Class_Profil::getPortail()->getMailSiteOrPortail(); } diff --git a/tests/library/Class/LeKioskLinkTest.php b/tests/library/Class/LeKioskLinkTest.php index e406263b27fa3f248889df70e81434b67385dcbd..fa1a02e8d7eaab4f7c422bd0ee1397cd012d628c 100644 --- a/tests/library/Class/LeKioskLinkTest.php +++ b/tests/library/Class/LeKioskLinkTest.php @@ -21,15 +21,39 @@ class LeKioskLinkTest extends Storm_Test_ModelTestCase { + public function setUp() { + parent::setUp(); + $this->fixture('Class_Profil', [ + 'id' => 1, + 'libelle' => 'portail', + 'mail_site' => '']); + + Class_AdminVar::newInstanceWithId('LEKIOSK_ID', ['valeur' => '29']); + } + + /** @test */ public function urlForMyemailAtLekioskDotComShouldBeAsExpected() { $expected = 'http://pro.lekiosk.com/lekiosque.authenticate.aspx?email=1671f18f515f49271985280397c1c2bc48e1bfa31a3b638cb22e510e4953d65e&id=29&AccessHash=e6715cdcc53d6d2b130f4025ea44b67872eb5455'; - - Class_AdminVar::newInstanceWithId('LEKIOSK_ID', ['valeur' => '29']); $this->assertEquals( $expected, Class_LeKioskLink::newFor('myemail@lekiosk.com')->url() ); } + + + /** @test */ + public function withoutMailShouldBeAsExpected() { + $expected = 'http://pro.lekiosk.com/lekiosque.authenticate.aspx?email=18ca3d8ad40255ce09d5d20debc1e069&id=29&AccessHash=b78f9cd4198878b85de383ccddd27ab286fc47f6'; + $this->assertEquals($expected, Class_LeKioskLink::newFor('')->url()); + } + + + /** @test */ + public function withEmptyUserMailShouldGetSiteOrProfileMail() { + Class_Profil::find(1)->setMailSite('toto@example.com'); + $expected = 'http://pro.lekiosk.com/lekiosque.authenticate.aspx?email=76903fe54055ab757db99c2370d89970e25c5b33b5a69cafc108c0031685af88&id=29&AccessHash=c5d56beb8fbd723bc562739cbc3f70ed43a79b9e'; + $this->assertEquals($expected, Class_LeKioskLink::newFor('')->url()); + } } ?> \ No newline at end of file