Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening File in Same Directory #15

Merged
merged 2 commits into from
Apr 29, 2023
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
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
Loading