Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
max-parallel: 6
matrix:
phpVersions: ['8.2', '8.3', '8.4']
phpVersions: ['8.2', '8.3', '8.4', '8.5']
fail-fast: false
name: PHP ${{ matrix.phpVersions }}
steps:
Expand Down
29 changes: 28 additions & 1 deletion src/Halcyon/Exception/ModelException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

use October\Rain\Halcyon\Model;
use October\Rain\Exception\ValidationException;
use Illuminate\Support\MessageBag;
use Exception;

/**
* ModelException used when validation fails, contains the invalid model for easy analysis
Expand All @@ -16,16 +18,41 @@ class ModelException extends ValidationException
*/
protected $model;

/**
* @var MessageBag validationErrors
*/
protected $validationErrors;

/**
* __construct receives the invalid model
*/
public function __construct(Model $model)
{
$this->model = $model;
$this->errors = $model->errors();
$this->validationErrors = $model->errors();

// Bypass parent constructor to avoid Validator facade dependency
Exception::__construct($this->validationErrors->first());

$this->evalErrors();
}

/**
* errors returns validation errors
*/
public function errors(): array
{
return $this->validationErrors->messages();
}

/**
* getErrors returns the message bag instance
*/
public function getErrors(): MessageBag
{
return $this->validationErrors;
}

/**
* getModel returns the model with invalid attributes
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Html/HtmlBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public static function limit($html, $maxLength = 100, $end = '...')
break;
}

if ($tag[0] === '&' || ord($tag) >= 0x80) {
if ($tag[0] === '&' || ord($tag[0]) >= 0x80) {
$result .= $tag;
$printedLength++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function get($key, array $replace = [], $locale = null, $fallback = true)

// Laravel notes that with JSON translations, there is no usage of a fallback language.
// The key is the translation. Here we extend the technology to add fallback support.
if ($fallback && $line === null) {
if ($fallback && $line === null && $this->fallback !== null) {
$this->load('*', '*', $this->fallback);
$line = $this->loaded['*']['*'][$this->fallback][$key] ?? null;
}
Expand Down
10 changes: 6 additions & 4 deletions tests/Html/HtmlBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ public function testLimit()
$result = with(new HtmlBuilder)->limit("<p>The quick brown fox jumped over the lazy dog</p><p>The quick brown fox jumped over the lazy dog</p>", 50);
$this->assertEquals('<p>The quick brown fox jumped over the lazy dog</p><p>The qu...</p>', $result);

$result = with(new HtmlBuilder)->limit(trim("
$input = str_replace("\r\n", "\n", trim("
<p>The quick brown fox jumped over the lazy dog</p>
<p>The quick brown fox jumped over the lazy dog</p>
"), 60);
"));
$result = with(new HtmlBuilder)->limit($input, 60);

$this->assertEquals(trim('
$expected = str_replace("\r\n", "\n", trim('
<p>The quick brown fox jumped over the lazy dog</p>
<p>The...</p>
'), $result);
'));
$this->assertEquals($expected, $result);
}

public function testClean()
Expand Down
1 change: 0 additions & 1 deletion tests/Mail/MailerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ protected static function callProtectedMethod($object, $name, $params = [])
$className = get_class($object);
$class = new ReflectionClass($className);
$method = $class->getMethod($name);
$method->setAccessible(true);
return $method->invokeArgs($object, $params);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Parse/MarkdownTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function testParseNonHtml()
$normal = $parser->parse($text);

// Only accepting one node per line
$this->assertEquals($expected, $normal);
$this->assertEquals(str_replace("\r\n", "\n", $expected), $normal);
}

public function testParseMultilineHtml()
Expand Down Expand Up @@ -149,6 +149,6 @@ public function testParseMultilineHtml()

$normal = $parser->parse($text);

$this->assertEquals($expected, $normal);
$this->assertEquals(str_replace("\r\n", "\n", $expected), $normal);
}
}
3 changes: 0 additions & 3 deletions tests/Parse/SyntaxFieldParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ protected static function callProtectedMethod($object, $name, $params = [])
$className = get_class($object);
$class = new ReflectionClass($className);
$method = $class->getMethod($name);
$method->setAccessible(true);
return $method->invokeArgs($object, $params);
}

Expand All @@ -331,7 +330,6 @@ public static function getProtectedProperty($object, $name)
$className = get_class($object);
$class = new ReflectionClass($className);
$property = $class->getProperty($name);
$property->setAccessible(true);
return $property->getValue($object);
}

Expand All @@ -340,7 +338,6 @@ public static function setProtectedProperty($object, $name, $value)
$className = get_class($object);
$class = new ReflectionClass($className);
$property = $class->getProperty($name);
$property->setAccessible(true);
return $property->setValue($object, $value);
}
}
3 changes: 0 additions & 3 deletions tests/Scaffold/ScaffoldBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ protected static function callProtectedMethod($object, $name, $params = [])
$className = get_class($object);
$class = new ReflectionClass($className);
$method = $class->getMethod($name);
$method->setAccessible(true);
return $method->invokeArgs($object, $params);
}

Expand All @@ -34,7 +33,6 @@ public static function getProtectedProperty($object, $name)
$className = get_class($object);
$class = new ReflectionClass($className);
$property = $class->getProperty($name);
$property->setAccessible(true);
return $property->getValue($object);
}

Expand All @@ -43,7 +41,6 @@ public static function setProtectedProperty($object, $name, $value)
$className = get_class($object);
$class = new ReflectionClass($className);
$property = $class->getProperty($name);
$property->setAccessible(true);
return $property->setValue($object, $value);
}

Expand Down
1 change: 0 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ protected static function callProtectedMethod($object, $name, $params = [])
$className = get_class($object);
$class = new ReflectionClass($className);
$method = $class->getMethod($name);
$method->setAccessible(true);
return $method->invokeArgs($object, $params);
}

Expand Down