Skip to content

Commit

Permalink
Merge pull request #15 from WebFiori/dev
Browse files Browse the repository at this point in the history
Opening File in Same Directory
  • Loading branch information
usernane committed Apr 29, 2023
2 parents 618c90a + 69109f2 commit 28636c5
Show file tree
Hide file tree
Showing 7 changed files with 247 additions and 190 deletions.
4 changes: 3 additions & 1 deletion example/upload-file.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
Expand All @@ -15,11 +16,12 @@
]);
$files = $u->uploadAsFileObj();
$file = $files[0];

if ($file instanceof UploadedFile) {
if (!$file->isUploaded()) {
http_response_code(404);
echo 'File not uploaded due to error code: '.$file->getUploadError();
} else {
echo 'Successfully uploaded.';
}
}
}
6 changes: 3 additions & 3 deletions php_cs.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ $finder = PhpCsFixer\Finder::create()
->in(__DIR__)
;

return PhpCsFixer\Config::create()
->setRules([
$config = new PhpCsFixer\Config();
return $config->setRules([
'align_multiline_comment' => [
'comment_type' => 'phpdocs_only'
],
Expand Down Expand Up @@ -54,7 +54,7 @@ return PhpCsFixer\Config::create()
'sort_algorithm' => 'alpha'
],
'ordered_class_elements' => [
'sortAlgorithm' => 'alpha',
'sort_algorithm' => 'alpha',
'order' => [
'constant_public',
'constant_protected',
Expand Down
12 changes: 12 additions & 0 deletions tests/webfiori/framework/test/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ public function test07() {
$this->expectExceptionMessage("No data is set to write.");
$file->write(false, true);
}
/**
* @test
*/
public function test08() {
$file = new File('in-dir.txt');
$file->read(0, 1);
$this->assertEquals('T', $file->getRawData());
$this->assertEquals([84], $file->toBytesArray());
$this->assertEquals(['54'], $file->toHexArray());
$file->read();
$this->assertEquals("This is to test if read from same directory is working.\n", $file->getRawData());
}
/**
* @test
*/
Expand Down
1 change: 1 addition & 0 deletions tests/webfiori/framework/test/in-dir.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is to test if read from same directory is working.
Loading

0 comments on commit 28636c5

Please sign in to comment.