Skip to content

Commit

Permalink
update to 5.6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
albertcht committed Jul 21, 2018
1 parent 734a8ec commit 7ef7f24
Show file tree
Hide file tree
Showing 3 changed files with 280 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/Concerns/MakesHttpRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ protected function transformHeadersToServerVars(array $headers)
*/
protected function formatServerHeaderKey($name)
{
if (! Str::startsWith($name, 'HTTP_') && $name != 'CONTENT_TYPE' && $name != 'REMOTE_ADDR') {
if (! Str::startsWith($name, 'HTTP_') && $name !== 'CONTENT_TYPE' && $name !== 'REMOTE_ADDR') {
return 'HTTP_'.$name;
}

Expand Down
88 changes: 88 additions & 0 deletions src/Constraints/SeeInOrder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

namespace AlbertCht\Lumen\Testing\Constraints;

use ReflectionClass;
use PHPUnit\Framework\Constraint\Constraint;

class SeeInOrder extends Constraint
{
/**
* The string under validation.
*
* @var string
*/
protected $content;

/**
* The last value that failed to pass validation.
*
* @var string
*/
protected $failedValue;

/**
* Create a new constraint instance.
*
* @param string $content
* @return void
*/
public function __construct($content)
{
$this->content = $content;
}

/**
* Determine if the rule passes validation.
*
* @param array $values
* @return bool
*/
public function matches($values)
{
$position = 0;

foreach ($values as $value) {
if (empty($value)) {
continue;
}

$valuePosition = mb_strpos($this->content, $value, $position);

if ($valuePosition === false || $valuePosition < $position) {
$this->failedValue = $value;

return false;
}

$position = $valuePosition + mb_strlen($value);
}

return true;
}

/**
* Get the description of the failure.
*
* @param array $values
* @return string
*/
public function failureDescription($values)
{
return sprintf(
'Failed asserting that \'%s\' contains "%s" in specified order.',
$this->content,
$this->failedValue
);
}

/**
* Get a string representation of the object.
*
* @return string
*/
public function toString()
{
return (new ReflectionClass($this))->name;
}
}
Loading

0 comments on commit 7ef7f24

Please sign in to comment.