Skip to content

Commit

Permalink
Replace deprecated assert methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Aug 16, 2023
1 parent d0a9793 commit 2d3e2da
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 70 deletions.
4 changes: 2 additions & 2 deletions tests/Phug/Adapter/FileAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ public function testCacheErrorTrace()
'count' => 0,
]);

self::assertContains('on line 5, offset 6', $lastError);
self::assertStringContainsString('on line 5, offset 6', $lastError);
}

/**
Expand Down Expand Up @@ -673,7 +673,7 @@ public function testCacheDirectory()
self::assertSame(2, $errErrors);
self::assertStringEndsWith('errored', $errErrorDetails[0]['directory']);
self::assertStringEndsWith('errored.pug', $errErrorDetails[0]['inputFile']);
self::assertContains(
self::assertStringContainsString(
'Inconsistent indentation. Expecting either 0 or 4 spaces/tabs.',
$errErrorDetails[0]['error']->getMessage()
);
Expand Down
2 changes: 1 addition & 1 deletion tests/Phug/CompilerModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testCompileEvent()
$message = $exception->getMessage();
}

self::assertContains('foo-bar.pug', $message);
self::assertStringContainsString('foo-bar.pug', $message);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Phug/OptimizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ public function testCache()
$contents .= file_get_contents($file);
}

self::assertContains('<p>A</p>', $contents);
self::assertContains('<p>B</p>', $contents);
self::assertStringContainsString('<p>A</p>', $contents);
self::assertStringContainsString('<p>B</p>', $contents);

$this->removeFile($cache);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Phug/Parser/TokenHandler/ExpansionTokenHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function testHandleTokenElementException()
$message = $exp->getMessage();
}

self::assertContains('Expansion needs an element to work on', $message);
self::assertContains('Path: my-path', $message);
self::assertStringContainsString('Expansion needs an element to work on', $message);
self::assertStringContainsString('Path: my-path', $message);
}
}
58 changes: 29 additions & 29 deletions tests/Phug/ProfilerModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ public function testRenderProfiler()
$render = $renderer->render('div');

self::assertRegExp('/div lexing\s*<br>\s*[\.\d]+[µm]?s/', $render);
self::assertContains('title="div lexing:', $render);
self::assertStringContainsString('title="div lexing:', $render);
self::assertRegExp('/div parsing\s*<br>\s*[\.\d]+[µm]?s/', $render);
self::assertContains('title="div parsing:', $render);
self::assertStringContainsString('title="div parsing:', $render);
self::assertRegExp('/div compiling\s*<br>\s*[\.\d]+[µm]?s/', $render);
self::assertContains('title="div compiling:', $render);
self::assertStringContainsString('title="div compiling:', $render);
self::assertRegExp('/div formatting\s*<br>\s*[\.\d]+[µm]?s/', $render);
self::assertContains('title="div formatting:', $render);
self::assertStringContainsString('title="div formatting:', $render);
self::assertRegExp('/div rendering\s*<br>\s*[\.\d]+[µm]?s/', $render);
self::assertContains('title="div rendering:', $render);
self::assertStringContainsString('title="div rendering:', $render);

$renderer = new Renderer([
'enable_profiler' => true,
Expand Down Expand Up @@ -118,15 +118,15 @@ public function testLogProfiler()
$profiler->recordDisplayEvent(1);
self::assertCount($count, $profiler->getEvents());
self::assertRegExp('/div lexing\s*<br>\s*[\.\d]+[µm]?s/', $render);
self::assertContains('title="div lexing:', $render);
self::assertStringContainsString('title="div lexing:', $render);
self::assertRegExp('/div parsing\s*<br>\s*[\.\d]+[µm]?s/', $render);
self::assertContains('title="div parsing:', $render);
self::assertStringContainsString('title="div parsing:', $render);
self::assertRegExp('/div compiling\s*<br>\s*[\.\d]+[µm]?s/', $render);
self::assertContains('title="div compiling:', $render);
self::assertStringContainsString('title="div compiling:', $render);
self::assertRegExp('/div formatting\s*<br>\s*[\.\d]+[µm]?s/', $render);
self::assertContains('title="div formatting:', $render);
self::assertStringContainsString('title="div formatting:', $render);
self::assertRegExp('/div rendering\s*<br>\s*[\.\d]+[µm]?s/', $render);
self::assertContains('title="div rendering:', $render);
self::assertStringContainsString('title="div rendering:', $render);
}

/**
Expand Down Expand Up @@ -217,7 +217,7 @@ public function testExecutionMaxTime()
$message = $exception->getMessage();
}

self::assertContains('execution_max_time of 3ms exceeded.', $message);
self::assertStringContainsString('execution_max_time of 3ms exceeded.', $message);
}

/**
Expand Down Expand Up @@ -267,7 +267,7 @@ public function testMemoryLimit()

unset($GLOBALS['LAkjdJHSmlakSJHGdjAJGdjGAHgsjHDAD']);

self::assertContains('memory_limit of '.$limit.'B exceeded.', $message);
self::assertStringContainsString('memory_limit of '.$limit.'B exceeded.', $message);
}

/**
Expand All @@ -288,16 +288,16 @@ public function testTokenDump()
]);
$render = $renderer->render("a(href='a')\n | Hello\ndiv");

self::assertContains('', $render);
self::assertContains('new line', $render);
self::assertContains('', $render);
self::assertContains('indent', $render);
self::assertContains('', $render);
self::assertContains('outdent', $render);
self::assertContains('(', $render);
self::assertContains('attributes start', $render);
self::assertContains(')', $render);
self::assertContains('attributes end', $render);
self::assertStringContainsString('', $render);
self::assertStringContainsString('new line', $render);
self::assertStringContainsString('', $render);
self::assertStringContainsString('indent', $render);
self::assertStringContainsString('', $render);
self::assertStringContainsString('outdent', $render);
self::assertStringContainsString('(', $render);
self::assertStringContainsString('attributes start', $render);
self::assertStringContainsString(')', $render);
self::assertStringContainsString('attributes end', $render);
}

/**
Expand Down Expand Up @@ -342,16 +342,16 @@ public function testDisplayProfiler()
ob_end_clean();

self::assertRegExp('/div lexing\s*<br>\s*[\.\d]+[µm]?s/', $contents);
self::assertContains('title="div lexing:', $contents);
self::assertStringContainsString('title="div lexing:', $contents);
self::assertRegExp('/div parsing\s*<br>\s*[\.\d]+[µm]?s/', $contents);
self::assertContains('title="div parsing:', $contents);
self::assertStringContainsString('title="div parsing:', $contents);
self::assertRegExp('/div compiling\s*<br>\s*[\.\d]+[µm]?s/', $contents);
self::assertContains('title="div compiling:', $contents);
self::assertStringContainsString('title="div compiling:', $contents);
self::assertRegExp('/div formatting\s*<br>\s*[+-]?[\.\d]+[µm]?s/', $contents);
self::assertContains('title="div formatting:', $contents);
self::assertStringContainsString('title="div formatting:', $contents);
self::assertRegExp('/div rendering\s*<br>\s*[\.\d]+[µm]?s/', $contents);
self::assertContains('title="div rendering:', $contents);
self::assertContains('-void-dump-', $contents);
self::assertStringContainsString('title="div rendering:', $contents);
self::assertStringContainsString('-void-dump-', $contents);
}

/**
Expand Down Expand Up @@ -401,7 +401,7 @@ public function testCustomDump()

$render = $renderer->render('div');

self::assertContains('Phug\\Compiler\\Event\\NodeEvent', $render);
self::assertStringContainsString('Phug\\Compiler\\Event\\NodeEvent', $render);
}

/**
Expand Down
64 changes: 32 additions & 32 deletions tests/Phug/RendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ public function testBasedir()
]);
$paths = $renderer->getCompiler()->getOption('paths');
self::assertCount(2, $paths);
self::assertContains('a', $paths);
self::assertContains('b', $paths);
self::assertStringContainsString('a', $paths);
self::assertStringContainsString('b', $paths);
}

/**
Expand Down Expand Up @@ -478,12 +478,12 @@ public function testHandleErrorInString()
$message = $error->getMessage();
}

self::assertContains(
self::assertStringContainsString(
'Division by zero',
$message
);

self::assertNotContains(
self::assertStringNotContainsString(
'trigger_error("Division'.'by'.'zero")',
str_replace(' ', '', $message)
);
Expand All @@ -497,12 +497,12 @@ public function testHandleErrorInString()
$message = $error->getMessage();
}

self::assertContains(
self::assertStringContainsString(
'Division by zero on line 1',
$message
);

self::assertContains(
self::assertStringContainsString(
'trigger_error("Division'.'by'.'zero")',
str_replace(' ', '', $message)
);
Expand All @@ -516,12 +516,12 @@ public function testHandleErrorInString()
$message = $error->getMessage();
}

self::assertContains(
self::assertStringContainsString(
'Division by zero on line 1',
$message
);

self::assertContains(
self::assertStringContainsString(
"\033[43;30m> 1 | div: p\033[43;31m=\033[43;30mtrigger_error(\"Division by zero\")\e[0m\n",
$message
);
Expand Down Expand Up @@ -575,18 +575,18 @@ public function testContextLines()
$message = $error->getMessage();
}

self::assertContains('Division by zero', $message);
self::assertContains('div: p=12/0', $message);
self::assertContains('// line -1', $message);
self::assertContains('// line +1', $message);
self::assertContains('// line -2', $message);
self::assertContains('// line +2', $message);
self::assertContains('// line -3', $message);
self::assertContains('// line +3', $message);
self::assertNotContains('// line -4', $message);
self::assertNotContains('// line +4', $message);
self::assertNotContains('// line -5', $message);
self::assertNotContains('// line +5', $message);
self::assertStringContainsString('Division by zero', $message);
self::assertStringContainsString('div: p=12/0', $message);
self::assertStringContainsString('// line -1', $message);
self::assertStringContainsString('// line +1', $message);
self::assertStringContainsString('// line -2', $message);
self::assertStringContainsString('// line +2', $message);
self::assertStringContainsString('// line -3', $message);
self::assertStringContainsString('// line +3', $message);
self::assertStringNotContainsString('// line -4', $message);
self::assertStringNotContainsString('// line +4', $message);
self::assertStringNotContainsString('// line -5', $message);
self::assertStringNotContainsString('// line +5', $message);
}

/**
Expand Down Expand Up @@ -624,17 +624,17 @@ public function testHandleErrorInFile()
$renderer->renderFile($path);
$message = str_replace('implode(): Invalid arguments passed', 'array, string given', $message ?: '');

self::assertContains(
self::assertStringContainsString(
'array, string given',
$message
);

self::assertNotContains(
self::assertStringNotContainsString(
'on line 3',
$message
);

self::assertNotContains(
self::assertStringNotContainsString(
$path,
$message
);
Expand All @@ -644,17 +644,17 @@ public function testHandleErrorInFile()
$renderer->renderFile($path);
$message = str_replace('implode(): Invalid arguments passed', 'array, string given', $message ?: '');

self::assertContains(
self::assertStringContainsString(
'array, string given on line 3, offset 2',
$message
);

self::assertContains(
self::assertStringContainsString(
$path,
$message
);

self::assertContains(
self::assertStringContainsString(
"implode('','')",
$message
);
Expand Down Expand Up @@ -814,8 +814,8 @@ public function testHandleHtmlError()
/* @var RendererException $lastError */
self::assertInstanceOf(RendererException::class, $lastError);
$message = $lastError->getMessage();
self::assertContains('Division by zero on line 1, offset 7', $message);
self::assertContains('<span class="error-line">'.
self::assertStringContainsString('Division by zero on line 1, offset 7', $message);
self::assertStringContainsString('<span class="error-line">'.
'div: p=<span class="error-offset">1</span>2/0</span>', $message);
}
}
Expand Down Expand Up @@ -884,10 +884,10 @@ public function testHandleParseError()
$message = $error->getMessage();
}

self::assertContains('ParseError:', $message);
self::assertContains(' on line 12, offset 12', $message);
self::assertContains('title Foo', $message);
self::assertNotContains('Too far to be visible error context', $message);
self::assertStringContainsString('ParseError:', $message);
self::assertStringContainsString(' on line 12, offset 12', $message);
self::assertStringContainsString('title Foo', $message);
self::assertStringNotContainsString('Too far to be visible error context', $message);
}

public function testHeadIndent()
Expand Down
4 changes: 2 additions & 2 deletions tests/Phug/Util/SandBoxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testError()
});

self::assertInstanceOf(Exception::class, $sandBox->getThrowable());
self::assertContains('Division by zero', $sandBox->getThrowable()->getMessage());
self::assertStringContainsString('Division by zero', $sandBox->getThrowable()->getMessage());
self::assertNull($sandBox->getResult());
self::assertSame('foo', $sandBox->getBuffer());

Expand All @@ -77,7 +77,7 @@ public function testError()
});

self::assertInstanceOf(Exception::class, $sandBox->getThrowable());
self::assertContains('Notice', $sandBox->getThrowable()->getMessage());
self::assertStringContainsString('Notice', $sandBox->getThrowable()->getMessage());

$level = error_reporting();

Expand Down

0 comments on commit 2d3e2da

Please sign in to comment.