-
-
Save JoelLarson/d762b13df87ebbd2b4e54a9a4535bd40 to your computer and use it in GitHub Desktop.
Is random in test always bad?
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 Demo | |
{ | |
protected $Property; | |
public function getProperty() | |
{ | |
return $this->Property; | |
} | |
public function setProperty($Value) | |
{ | |
$this->Property = $Value; | |
} | |
} | |
class DemoTest extends TestCase | |
{ | |
public function setUp() | |
{ | |
$this->demo = new Demo(); | |
} | |
public function testInvalidProperty() { | |
try { | |
$this->demo->setProperty(null); | |
} catch (\DomainException $e) { | |
return; | |
} | |
$this->throw('Demo property can not be set to null'); | |
} | |
public function testProperty() | |
{ | |
$this->demo->setProperty("demo_property"); | |
$this->assertProperty($this->demo, "demo_property"); | |
} | |
public function testComplicatedProperty() | |
{ | |
$this->demo->setProperty(array('hello' => 'world')); | |
$this->assertProperty($this->demo, array('hello' => 'world')); | |
} | |
private function assertProperty($demo, $expected) { | |
$this->assertEquals($demo->getProperty(), $expected); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment