PHPUnit_Framework_Testcase ํด๋์ค์์ assertEquals() ๋ฉ์๋๋ฅผ ์ฌ์ฉํ๊ณ ๋น๊ตํ ๋:
_NULL_์ ๋ํด _false_,
_false_์ ๋ํ _๋น ๋ฌธ์์ด_,
_NULL_์ ๋ํ _๋น ๋ฌธ์์ด_
๋ชจ๋ ํ ์คํธ๋ฅผ ์ฑ๊ณต์ ์ผ๋ก ํต๊ณผํ์ต๋๋ค. ๊ทธ๋ฌ๋ ์ด๋ค ๊ฐ์น๋ ์๋ก ๋์ผํ์ง ์์ต๋๋ค. ๋ฐ๋ผ์ assertEquals๋ "===" ๋๋ ์ด์ ์ ์ฌํ ๋์ "==" ์ฐ์ฐ์์ ๋น๊ตํฉ๋๋ค. ์๋ ๊ทธ๋๋ก๋ผ๊ณ ์๊ฐํ์ธ์. ํ์ง๋ง ์?
===
๋น๊ต๋ฅผ ์ํ assertSame()
์ด ์์ต๋๋ค.
์ข์ ์๋ฒฝํด. ์ด๋ฆ์ด ์ฝ๊ฐ ์คํด์ ์์ง๊ฐ ์์ต๋๋ค. ํ์ง๋ง ๋ด ์๋ชป์ด์ผ. ๊ทธ ์ฃ์กํฉ๋๋ค.
๊ทธ๋ฌ๋ assertSame()
๋ ๊ฐ์ฒด๊ฐ ๋์ผํ ๊ฒฝ์ฐ์๋ง true
๋น๊ตํฉ๋๋ค.
class Foo {}
$this->assertSame(new Foo(), new Foo());
Failed asserting that two variables reference the same object.
๋ค์๊ณผ ๊ฐ์ด ์๋ํ ์ ์๋ ์ฝ๋๊ฐ ํ์ํฉ๋๋ค.
$this->assertSame(new Foo(null), new Foo("")); // false
$this->assertSame(new Foo(null), new Foo(null)); // true
$this->assertSame(new Foo(""), new Foo("")); // true
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
===
๋น๊ต๋ฅผ ์ํassertSame()
์ด ์์ต๋๋ค.