Ejemplo n.º 1
0
 public function testIsEqualToFileContents()
 {
     $this->if($asserter = new sut($generator = new asserter\generator(), $adapter = new atoum\test\adapter()))->then->boolean($asserter->wasSet())->isFalse()->exception(function () use($asserter) {
         $asserter->isEqualToContentsOfFile(uniqid());
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Value is undefined')->if($asserter->setWith($firstString = uniqid()))->and($adapter->file_get_contents = false)->then->exception(function () use($asserter, &$path) {
         $asserter->isEqualToContentsOfFile($path = uniqid());
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('Unable to get contents of file %s'), $path))->if($adapter->file_get_contents = $fileContents = uniqid())->and($diff = new diffs\variable())->then->exception(function () use($asserter, &$path) {
         $asserter->isEqualToContentsOfFile($path);
     })->isInstanceOf('mageekguy\\atoum\\asserter\\exception')->hasMessage(sprintf($generator->getLocale()->_('string is not equals to contents of file %s'), $path) . PHP_EOL . $diff->setExpected($fileContents)->setActual($firstString))->if($adapter->file_get_contents = $firstString)->then->object($asserter->isEqualToContentsOfFile(uniqid()))->isIdenticalTo($asserter);
 }