for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace NwLaravel\Testing;
use Illuminate\Contracts\View;
use PHPUnit_Framework_TestCase as PHPUnit;
trait WebAssertTrait
{
/**
* Assert that the response view has name
*
* @param string $name
* @param string $message
*/
public function assertView($name, $message = '')
PHPUnit::assertThat($name, new ConstraintView($this->response), $message);
response
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
* Assert Trait Exists
* @param string $expected
* @param Object $object
* @return void
* @throws
public function assertTraitExists($expected, $object, $message = '')
$traits = class_uses($object);
$message = $message ?: sprintf("Failed asserting not exists Trait instance of interface '%s'.", $expected);
PHPUnit::assertArrayHasKey($expected, $traits, $message);
* Execute method protected
* @param object $object Object
* @param string $method Method a Execute
* @param array $args Params
public function callProtectedMethod($object, $method, array $args = array())
$class = new \ReflectionClass(get_class($object));
$method = $class->getMethod($method);
$method->setAccessible(true);
return $method->invokeArgs($object, $args);
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: