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

Mandiseli Mfeya Submission #28

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":1,"defects":{"Tests\\DatabaseConnectionTest::testDatabaseConnection":4},"times":{"Tests\\DatabaseConnectionTest::testDatabaseConnection":0.01}}
Binary file not shown.
Binary file not shown.
1,016 changes: 1,016 additions & 0 deletions .vs/PHP-assessment/config/applicationhost.config

Large diffs are not rendered by default.

Binary file added .vs/PHP-assessment/v17/.wsuo
Binary file not shown.
196 changes: 196 additions & 0 deletions .vs/PHP-assessment/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\config\\database.php||{3B902123-F8A7-4915-9F01-361F908088D0}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:config\\database.php||{3B902123-F8A7-4915-9F01-361F908088D0}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\models\\question.php||{3B902123-F8A7-4915-9F01-361F908088D0}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:models\\question.php||{3B902123-F8A7-4915-9F01-361F908088D0}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\lenovo\\Source\\Repos\\PHP-assessment\\mandiseli.sql||{CC5D8DF0-88F4-4BB2-9DBB-B48CEE65C30A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:mandiseli.sql||{CC5D8DF0-88F4-4BB2-9DBB-B48CEE65C30A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\core\\logging.php||{3B902123-F8A7-4915-9F01-361F908088D0}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:core\\logging.php||{3B902123-F8A7-4915-9F01-361F908088D0}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\boot.php||{3B902123-F8A7-4915-9F01-361F908088D0}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:boot.php||{3B902123-F8A7-4915-9F01-361F908088D0}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\README.md||{EFC0BB08-EA7D-40C6-A696-C870411A895B}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:README.md||{EFC0BB08-EA7D-40C6-A696-C870411A895B}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\composer.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:composer.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\tests\\testQuestion.php||{3B902123-F8A7-4915-9F01-361F908088D0}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:tests\\testQuestion.php||{3B902123-F8A7-4915-9F01-361F908088D0}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\tests\\testBasics.php||{3B902123-F8A7-4915-9F01-361F908088D0}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:tests\\testBasics.php||{3B902123-F8A7-4915-9F01-361F908088D0}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\core\\database.php||{3B902123-F8A7-4915-9F01-361F908088D0}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:core\\database.php||{3B902123-F8A7-4915-9F01-361F908088D0}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\lenovo\\Source\\Repos\\PHP-assessment\\mandiseli.sql||{CC5D8DF0-88F4-4BB2-9DBB-B48CEE65C30A}|CodeFrame",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:mandiseli.sql||{CC5D8DF0-88F4-4BB2-9DBB-B48CEE65C30A}|CodeFrame"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 4,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
},
{
"$type": "Document",
"DocumentIndex": 6,
"Title": "composer.json",
"DocumentMoniker": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\composer.json",
"RelativeDocumentMoniker": "composer.json",
"ToolTip": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\composer.json",
"RelativeToolTip": "composer.json",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001642|",
"WhenOpened": "2024-06-22T15:11:48.377Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "logging.php",
"DocumentMoniker": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\core\\logging.php",
"RelativeDocumentMoniker": "core\\logging.php",
"ToolTip": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\core\\logging.php",
"RelativeToolTip": "core\\logging.php",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAA0AAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.002338|",
"WhenOpened": "2024-06-22T14:47:49.167Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 9,
"Title": "database.php",
"DocumentMoniker": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\core\\database.php",
"RelativeDocumentMoniker": "core\\database.php",
"ToolTip": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\core\\database.php",
"RelativeToolTip": "core\\database.php",
"ViewState": "AQIAAEgAAAAAAAAAAAAcwGcAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.002338|",
"WhenOpened": "2024-06-22T14:42:35.864Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "database.php",
"DocumentMoniker": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\config\\database.php",
"RelativeDocumentMoniker": "config\\database.php",
"ToolTip": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\config\\database.php",
"RelativeToolTip": "config\\database.php",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAEoAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.002338|",
"WhenOpened": "2024-06-22T14:18:42.821Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "question.php",
"DocumentMoniker": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\models\\question.php",
"RelativeDocumentMoniker": "models\\question.php",
"ToolTip": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\models\\question.php",
"RelativeToolTip": "models\\question.php",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAD4AAAAlAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.002338|",
"WhenOpened": "2024-06-22T14:14:07.537Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 7,
"Title": "testQuestion.php",
"DocumentMoniker": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\tests\\testQuestion.php",
"RelativeDocumentMoniker": "tests\\testQuestion.php",
"ToolTip": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\tests\\testQuestion.php",
"RelativeToolTip": "tests\\testQuestion.php",
"ViewState": "AQIAAA8AAAAAAAAAAAAAADwAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.002338|",
"WhenOpened": "2024-06-22T14:13:27.112Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 8,
"Title": "testBasics.php",
"DocumentMoniker": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\tests\\testBasics.php",
"RelativeDocumentMoniker": "tests\\testBasics.php",
"ToolTip": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\tests\\testBasics.php",
"RelativeToolTip": "tests\\testBasics.php",
"ViewState": "AQIAAAAAAAAAAAAAAAAAACAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.002338|",
"WhenOpened": "2024-06-22T14:13:18.658Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 4,
"Title": "boot.php",
"DocumentMoniker": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\boot.php",
"RelativeDocumentMoniker": "boot.php",
"ToolTip": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\boot.php",
"RelativeToolTip": "boot.php",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAsAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.002338|",
"WhenOpened": "2024-06-22T14:12:18.257Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 5,
"Title": "README.md",
"DocumentMoniker": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\README.md",
"RelativeDocumentMoniker": "README.md",
"ToolTip": "C:\\Users\\lenovo\\source\\repos\\PHP-assessment\\README.md",
"RelativeToolTip": "README.md",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001818|",
"WhenOpened": "2024-06-22T14:11:00.071Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "mandiseli.sql ",
"DocumentMoniker": "C:\\Users\\lenovo\\Source\\Repos\\PHP-assessment\\mandiseli.sql",
"RelativeDocumentMoniker": "mandiseli.sql",
"ToolTip": "mandiseli.sql ",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000826|",
"WhenOpened": "2024-06-22T14:10:31.595Z",
"EditorCaption": ""
}
]
}
]
}
]
}
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
8 changes: 8 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"ExpandedNodes": [
"",
"\\config"
],
"SelectedNode": "\\mandiseli.sql",
"PreviewInSolutionExplorer": false
}
Binary file added .vs/slnx.sqlite
Binary file not shown.
79 changes: 51 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,51 @@
Technical Skills Assessment (PHP)
=================================

Requirements

* Local development environment with PHP (5.4+) interpreter and MySQL (5.5+) server

Instructions

1. Create a Github account if you don’t have one already
2. Send an email to jason at leadwrench dot com with the subject of “PHP Skills Assessment” and include your Github
account ID in the body. You will have 2 hours to complete the assessment from the time you send this email.
3. Fork the repository at: https://github.com/edgeprod/PHP-assessment into your account
4. Pull your forked repository into your IDE
5. Fix any PHP syntax errors you find. Errors have been intentionally placed in the code.
6. Modify code to meet PSR-1 and PSR-2 code style guidelines. Do NOT incorporate PSR-0 or PSR-4, as required by PSR-1.
Make use of self-documenting code principles where necessary. Identify and use other existing style conventions.
7. Initialize and run Composer to get needed dependencies
8. Create a MySQL database and import the ‘schema.sql’ file
9. Update ‘config/database.php’ with credentials to access newly created database
10. Run unit tests to see remaining failures
11. Make needed changes so all unit tests pass, however do NOT change the unit tests in any way.
12. Push ALL changes back to your forked repository, including database changes (into schema.sql)
13. Replace that ‘README.md’ file with the output of all the unit tests passing
14. Create a Pull Request to integrate the fixed code back into the master repository. The Pull Request will ultimately
not be merged but will signal your completion of the skills assessment.

Please ask for clarification if you have a question. Guessing an answer to an ambiguous directive will count against you.
Error Encountered in PHPUnit Testing
==============================================

Error Message:
-------------------------------------------------
------------------------------------------------------
PHPUnit 8.5.38 by Sebastian Bergmann and contributors.

E 1 / 1 (100%)

Time: 540 ms, Memory: 4.00 MB

There was 1 error:

1) Tests\DatabaseConnectionTest::testDatabaseConnection
Error: Class "config\Config_Database" not found

C:\Users\lenovo\source\repos\PHP-assessment\core\database.php:16
C:\Users\lenovo\source\repos\PHP-assessment\tests\DatabaseConnectionTest.php:13

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.


Description:
----------------------------------------------------------------------
During the execution of PHPUnit tests in my project (PHP-assessment), an error occurred related to the class Config_Database not being found. This error specifically happened when PHPUnit attempted to run the DatabaseConnectionTest::testDatabaseConnection test method.

Probable Causes:
--------------------------------------------------------------------------
Autoloading Issue: The autoloader might not be correctly configured to load the Config_Database class.
Namespace Mismatch: There could be a mismatch between the namespace defined in Config_Database and where PHPUnit expects to find it.
File Path or Name Issue: The file defining Config_Database might not exist or might be named differently than expected.


Steps Taken to Resolve:
------------------------------------------------------------
1. Checked the composer.json for correct autoloading configurations.
2. Verified the namespace and class name in Config_Database and DatabaseConnectionTest.php.
3. Ran composer dump-autoload to regenerate autoload files.
4. Reviewed the file path and ensured it matches the namespace structure.
Next Steps
5. To resolve this issue, I will continue investigating the autoloading setup and namespace/class definitions to ensure that PHPUnit can locate the Config_Database class during testing.

Additional Information:
--------------------------------------------------------------
1. PHPUnit Version: 8.5.38
2. Project Path: C:\Users\lenovo\source\repos\PHP-assessment
3. Affected Files:
3.1 core\database.php
3.2 tests\DatabaseConnectionTest.php
1 change: 1 addition & 0 deletions boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
//require_once __DIR__ . '/models/question.php';
require_once __DIR__ . '/config/database.php';
require_once __DIR__ . '/core/database.php';

17 changes: 15 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
{
"require-dev" : {
"phpunit/phpunit": "4.2.*"
"autoload": {
"psr-4": {
"config\\": "config/",
"interview\\": "core/",
"model\\": "model/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"require-dev": {
"phpunit/phpunit": "^8.5"
}
}

23 changes: 7 additions & 16 deletions config/database.php
Original file line number Diff line number Diff line change
@@ -1,48 +1,39 @@
<?php

namespace interview;
namespace config;

class Config_Database
{

private $credentials = array(
'host' => 'localhost',
'port' => NULL,
'database' => 'interview',
'user' => 'questions',
'pass' => 'answers'
'port' => 3306,
'database' => 'root',
'user' => 'mandiseli',
'pass' => '10/May/1989'
);

public function getHost()
{
return $this->credentials['host'];
}
//--------------------------------------------------------------------------


public function getPort{
public function getPort()
{
return $this->credentials['port'];
}
//--------------------------------------------------------------------------


public function getDatabase()
{
return $this->credentials['database'];
}
//--------------------------------------------------------------------------


public function getUser()
{
return $this->credentials['user'];
}
//--------------------------------------------------------------------------


public function getPass()
{
return $this->credentials['pass'];
}
//--------------------------------------------------------------------------
}
Loading