redbeanPHP database connect doesn´t work in phpUnit bootstrap - php

i am using redbeanPHP since two years.
On my new project i wan´t to implement unit-tests from the beginning.
I installed phpUnit and without the database connection all works fine. I now wan´t to test my classes with database intigration. I know this is not a unit-test anymore. But i thing it will help me a lot to auto test the functionality from the implementation.
I call R::setup("mysql:host=localhost;dbname=ufm","root","root"); in my setup file which i declared as bootstrap file for phpUnit.
If i now run my tests i get:
PDOException: Could not connect to database (ufm).
phar:///Applications/MAMP/htdocs/ufm/core/plugins/rb.phar/RedBeanPHP/Driver/RPDO.php:280
phar:///Applications/MAMP/htdocs/ufm/core/plugins/rb.phar/RedBeanPHP/Driver/RPDO.php:126
phar:///Applications/MAMP/htdocs/ufm/core/plugins/rb.phar/RedBeanPHP/Driver/RPDO.php:289
phar:///Applications/MAMP/htdocs/ufm/core/plugins/rb.phar/RedBeanPHP/Adapter/DBAdapter.php:79
phar:///Applications/MAMP/htdocs/ufm/core/plugins/rb.phar/RedBeanPHP/QueryWriter/AQueryWriter.php:576
phar:///Applications/MAMP/htdocs/ufm/core/plugins/rb.phar/RedBeanPHP/OODB.php:893
phar:///Applications/MAMP/htdocs/ufm/core/plugins/rb.phar/RedBeanPHP/Facade.php:463
/Applications/MAMP/htdocs/ufm/tests/TurnierTest.php:14
The strange thing is that i am using the same setup file in my normal application. There all works fine.
Has phpUnit or redbeanPHP any limitations for database connection in the bootstrap file? I searched for two days now but i can´t find any documentation about this. I only found a blogpost on google groups where some guy successfully makes the exact same thing.
Thanks for your help.
Best regards,schw4ndi

Try this:
R::setup("mysql:host=localhost;dbname=ufm;port=3306","root","root");
I added port number there see if that helps.
If you need a working Test Unit + Redbean example, you can try skully framework here: http://github.com/triodigital/skully-project
Setting up
Clone this project to your server.
Copy config/config.unique.php.original to config/config.unique.php and update the database information there.
Update baseUrl config in config/config.common.php.
Copy .htaccess.original to .htaccess and update the first line of that file.
Update the project by running './composer.phar install'.

I stumbled accros the same error again.
Just change the localhost to 127.0.0.1 and it works fine! Maybe it helps someone in the future.
R::setup("mysql:host=127.0.0.1;dbname=ufm","root","root");

Related

CakePHP CMS Cascading Delete works in local, but not in production?

So I've managed to deploy my CakePHP to EB and when I've tried testing by handling the User table. I've managed to create/edit a user, but when I try deleting one I get "Table class for alias TABLENAME could not be found." The funny thing is when I do the same thing, even connected to the same DB, with the same configuration, running the same command (PHP -S) this works in local so I'm pretty bamboozled. The first thing that came to mind is that my nginx is configured wrong, but I can normally edit and delete entries in the TABLENAME table so I'm assuming all files related can be located ? Also I've added the belongsTo and hasMany to respective table class files.
I honestly don't even know what to try anymore. Also for some reason my DebugKit won't work in EB either (works locally) so it's making my life so much tougher. Has anyone had any similar issues ? Thanks in advance :)

Laravel Configuration (No such file directory ~/.homestead/Homestead.yaml)

Hello, I wanted to try creating a Laravel Application and I am really new to this.
I tried all the best I can to analyze and implement the solutions of other people but to no success.
So I have followed the methods in configuring the Laravel App.
The ssh key has also been created in the homekey file as seen from the Homestead.yaml file, I edited it.
But when I try to do 'vagrant up'.
This error message begin to show.
It seems looking for the directory of .homestead but even I can't find it.
I don't know what step am I overlooking.

how can i import a project to cakephp?

I have my cakephp in this path of my computer C:\xampp\htdocs\cakephp and everything work fine, i made a few exercises and examples to know and learn more of cakephp and that projects and examples works fine too but her is the question, now i have other project with whole files how comes cakephp (app,lib,plugin,vendors etc..) this files running fine but i need to see his functionality because i need to modified or add some features (this is my goal) but i dont know how import or modified the route.php file in cakephp for use this whole project in my localhost.
One idea through my mind is take every single model,ctp file component etc.. and copy and paste from this new project to my cakephp but i dont have a very good feel about this idea, if some one could help me i'm going to be very grateful and thanks
From your question, I am getting that you want to maintain an existing CakePHP project.
Why don't you take a backup of the original working project, make a copy of it (with a different name in your XAMPP) and work on it? Once satisfied, you can present the new copy as the final project. You may have to change some settings to make the copied project work.
In other words, if you can get one project to work on XAMPP, why not just take a backup, then edit it as per the requirements.

How to run a Yii project developed by someone else?

I am continuing on someone's project developed on Yii. The guy has to transfer the files to me. What I got was a folder with project files and folders (such as protected and public) and a db dump. I am currently testing it on wamp. I have imported the db dump using phpmyadmin, and also updated the db access credentials in project\protected\config\main.php.
I have worked a lot on php and its frameworks, but this is my first experience with Yii. I tried to google but every tutorial tells how to create and run a new project and not an existing one.
So can someone please guide me as how can I run this Yii project?
Go through docs first
The official web-site
Class Reference
Building a blog tutorial. This must answer all your questions

FuelPHP's Autoloader is failing to find classes

I'm having a problem with FuelPHP failing to autoload classes. On my staging server (Ubuntu, PHP 5.3.10) it is unable to find custom classes in the fuel/app/classes directory, and it also can't run oil test (I get the error message sh: 1: phpunit: not found). Oddly, it works fine on my local development version (Windows, PHP 5.3.6).
I suspected it might have something to do with Composer, which I'm using for the first time on this project, but the problem is not fixed when I comment out the line require APPPATH.'vendor/autoload.php'; from bootstrap.php (the app still fails to load custom classes from fuel/app/classes)
I'm stumped: I've used FuelPHP on lots of projects and have never had any problems with the Autoloader. What's particularly puzzling is that the same code seems to work fine in one place and not in another. I'd be very grateful for any suggestions about how to fix this.
I realize this question was asked a long time ago, but I had the same problem, so for the benefit of anyone else with this problem, here is what worked for me:
create a new php file called oil.php in the app/config directory with the following code:
<?php
// Unit tests will get shell error 'phpunit: command not found' unless
// the path to php unit is specified.
return array (
'phpunit' => array (
'binary_path' => 'fuel/vendor/bin/phpunit',
),
);
I am using fuel 1.7.2. More information can be found here.
Although the above code fixed the specific PHPunit problems, I still had issues with Fuel and autoloaders not working. Fuel PHP does not follow psr-4 (many of the core fuel files have multiple class definitions in the same file), which can cause problems with certain autoloaders.

Categories