Beispiel #1
0
 public function testIsEqualToFileContents()
 {
     $this->if($asserter = new asserters\utf8String($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 = $this->getRandomUtf8String()))->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 = $this->getRandomUtf8String())->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->setReference($fileContents)->setData($firstString))->if($adapter->file_get_contents = $firstString)->then->object($asserter->isEqualToContentsOfFile($this->getRandomUtf8String()))->isIdenticalTo($asserter);
 }