-
-
Save aurelijusb/fbf67808f8c58c6910ee to your computer and use it in GitHub Desktop.
Medžaiaga skaidrėms: Išlipus iš 1 PHP failo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$today = date('Y-m-d'); | |
if (date('z') == 0xFF) { | |
echo "Programuotojų diena"; | |
} else if ('2015-10-10' <= $today && $today <= '2015-10-10') { | |
echo "Programuotojų savaitė"; | |
} else { | |
echo "Paprasta diena"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Events | |
{ | |
public function isProgrammersDay($today) | |
{ | |
return date('z', strtotime($today)) == 0xFF; | |
} | |
public function isCodeWeek($today) | |
{ | |
$date = date('Y-m-d', strtotime($today)); | |
return '2015-10-10' <= $date && $date <= '2015-10-18'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class EventsTest extends PHPUnit_Framework_TestCase { | |
public function testCodeWeek2015() | |
{ | |
$service = new Events(); | |
$this->assertTrue($service->isCodeWeek('2015-10-10')); | |
$this->assertTrue($service->isCodeWeek('2015-10-15')); | |
$this->assertTrue($service->isCodeWeek('2015-10-18')); | |
$this->assertFalse($service->isCodeWeek('2015-10-09')); | |
$this->assertFalse($service->isCodeWeek('2015-10-19')); | |
$this->assertFalse($service->isCodeWeek('2015-01-01')); | |
} | |
public function testCodeWeek2014() | |
{ | |
$service = new Events(); | |
$this->assertTrue($service->isCodeWeek('2014-10-10')); | |
$this->assertTrue($service->isCodeWeek('2014-10-15')); | |
$this->assertTrue($service->isCodeWeek('2014-10-18')); | |
$this->assertFalse($service->isCodeWeek('2014-10-09')); | |
$this->assertFalse($service->isCodeWeek('2014-10-19')); | |
$this->assertFalse($service->isCodeWeek('2014-01-01')); | |
} | |
public function testProgrammersDay() | |
{ | |
$service = new Events(); | |
$this->assertTrue($service->isProgrammersDay('2015-09-13')); | |
$this->assertFalse($service->isProgrammersDay('2015-10-15')); | |
$this->assertTrue($service->isProgrammersDay('2014-09-13')); | |
$this->assertFalse($service->isProgrammersDay('2014-09-14')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment