2
votes
1answer
34 views

Is it necessary to test relationships in both directions?

I'm attempting to test relationships between models using Ardent and FactoryMuff. I'm able to test the relationship in the belongs_to direction, but I'm having trouble testing it in the has_many ...
2
votes
1answer
54 views

PHPUnit 3.7 can't find Controller Classes in Laravel 4.1

Setup 1: Echoing back from the route works in PHPUnit routes.php Route::get('signup', function(){ return "Hello World!"; }); /tests/SignupTest.php class SignupTest extends TestCase { ...
0
votes
0answers
23 views

laravel phpunit mocked method requiring an array even when withAnyArgs() is called?

below is my controller class and the relevant method and my test class and relevant test. when the mocked method $this->user->update() runs I get this error Time: 1.08 seconds, Memory: 31.00Mb ...
0
votes
2answers
16 views

mockery->shouldReceive() passing when it shouldnt?

I am learning unit testing in laravel using phpunit and mockery. I am currently trying to test UsersController::store(). I am mocking User Model and using it to test the index method and that ...
0
votes
0answers
39 views

phpunit cant find eloquent class in laravel

I am following the laravel testing decoded book and have gotten into a spot were I don't know what I have done wrong or how to fix it. When I run phpunit I get this error PHP Fatal error: Class ...
0
votes
1answer
37 views

Laravel Testing with assertTrue method error on simple test

Im trying to do a real simple test going with Laravel 4 but getting errors. Here is my super simple test. class SignupTest extends TestCase { public function testIndex() { ...
1
vote
0answers
71 views

testing php laravel controller shouldReceive arguments

I have a laravel model which uses ardent/eloquent. I am trying to set up tests for the controller in particular, storing a new model that uses the ardent model. The method works in the app but I'm ...
8
votes
1answer
218 views

Eager loading has some unexpected side effects on Model events/ booting in Laravel

I'm trying to create some tests. Here's my Test Class: class ExampleTest extends TestCase { public function setUp() { parent::setUp(); Artisan::call('migrate'); ...
0
votes
1answer
69 views

Laravel testing mocked object method not found

Ok - my rocky road journey into testing (with laravel) continues... I have created an instance and a 'repository' which I'm now trying to test. However on doing so I get an error that the method in ...
0
votes
1answer
68 views

trouble geting started with laravel testing and mockery

I'm trying to get started on unit testing with laravel and am trying to follow a couple of tutorials. Alot of my controllers have been generated using Jeffrey Ways excellent generators and they ...
0
votes
2answers
64 views

Can you have two instances of a model in one test function in phpunit?

I'm trying to test that a duplicate user cannot be inserted. To do this, I am creating 2 user objects with the same details, just changing account name - since this is something that is also unique. ...
1
vote
1answer
255 views

Laravel 4 model unit test with Codeception - Class 'Eloquent' not found

I'm trying to use Codeception to run my Laravel 4 unit tests. Running a test for a simple class with no dependencies works fine. But when I instantiate a model which depends on Eloquent, I get this ...
0
votes
1answer
76 views

Getting laravel & phpunit to send message when unit test fails

I am using a function that tests for existence of an array in each page. I am using laravel's function assertViewHas. This would be fine if I had a function for each page testing for this array ...
1
vote
1answer
106 views

How to test namespaced objects in Laravel 4 with phpunit

I'm organizing my tests folder to reflect the namespaced objects and interfaces in my app. However, I've been running into nothing but trouble trying to maintain order while practicing TDD with ...
0
votes
1answer
141 views

Undefined variable in controller I am trying to test with phpunit in laravel

I am trying to learn the basics of unit testing and I am using phpunit and laravel Here is my controller FatController.php class FatController extends BaseController { public $result; ...
0
votes
0answers
125 views

PHPUnit Cannot redeclare class File_Iterator_Factory error in Laravel 4

I'm developed the application using Laravel 4 and install the PHPUnit using the composer. But when I run the "phpunit" command in the console I'm getting following error. Fatal error: Cannot ...
0
votes
1answer
113 views

What's the best way to unit test a controller in Laravel without testing the route too

I've read lots of documentation about testing controllers using $this->call($destination, $parameters, 'GET'); but this seems to rely on the route being set up too, and knowing the right ...
0
votes
3answers
146 views

phpunit cannot find Class, PHP Fatal error

I get phpunit and install it as this link using the simplest way for test purposes. I just download the phpunit.phar file, chmod & rename & move to /usr/local/bin Then, I run phpunit ...
0
votes
1answer
85 views

phpunit running exception when run a very very simple unit test

I get phpunit and install it as this link using the simplest way for test purposes. I just download the phpunit.phar file, chmod & rename & move to /usr/local/bin Then, I run phpunit ...
0
votes
2answers
194 views

Using phpunit in laravel 4 without /vendor/bin/

I have installed phpunit in this instance of laravel using composer. The files are present in the laravel/vendor/bin folder. when I run vendor/bin/phpunit the example test runs. In all the ...
0
votes
1answer
304 views

Unit testings Laravel 4 with PHPUnit

I've added "phpunit/phpunit": "3.7.*" to the require-dev section of composer.json and ran composer install. Unfortunately, when I run vendor/bin/phpunit from the root of my Larvel 4 project, I get the ...
0
votes
1answer
772 views

Laravel: Lacking mcrypt extension only when using phpunit

I have a following problem - when using phpunit in my Laravel 4 installation folder I get a following error: Laravel requires the Mcrypt PHP extension. However it does not appear when I'm using the ...
0
votes
0answers
96 views

Laravel Guard watching model/controller etc save not working

I'm trying to setup watching using Guard in my Laravel build. It's all installed and seems to be working however I want to set it to run tests when I save a Model/Controller whatever really. I've ...
0
votes
1answer
154 views

Laravel Mockery Integration Test

I am a little lost on how to perform integration test using mockery. I have the following classes: TeacherController TeacherManager - Interface TeacherManagerImpl - Implementation When it comes to ...
0
votes
1answer
296 views

Unit test laravel 4 controller passing JSON payload

app/controllers/SecurityController.php class SecurityController extends Controller { public function login() { $payload = file_get_contents("php://input"); $payload = ...
0
votes
1answer
97 views

Is there a better way to write this test?

I'm fairly new to unit testing with Laravel and Mockery and I wrote the following test. It passes and seems to work. However, I think that it's probably could be written in a better way. It seems that ...
2
votes
2answers
516 views

Laravel 4 PHP Fatal error: Class 'Illuminate\Foundation\Testing\TestCase' not found

I get the following error when I run phpunit with Laravel 4. PHP Fatal error: Class 'Illuminate\Foundation\Testing\TestCase' not found in composer.json "require": { "laravel/framework": ...
1
vote
1answer
60 views

Why having more than one test method in a file using Laravel raises error?

when I have more than one test in a testfile with laravel, and I execute them I get: Fatal error: Cannot redeclare nameSort() (previously declared in C:\wamp\www\project\app\start\global.php:110) in ...
0
votes
2answers
140 views

phpunit gives errors even with no tests (Laravel)

Hi I just download phpunit.phar in my laravel project (which I already developed partly). I started by doing a simple php phpunit.phar but it outputs things like whole viewfiles with at the end: ...
3
votes
1answer
141 views

Why does phpunit not show any errors in the console

I'm using phpunit with Laravel 4 framework. Why is it that when there's a PHP error during the tests, no error messages are shown (eg: missing method)? How can we get phpunit to show all errors?
0
votes
0answers
112 views

Mocking Illuminate\Database\Eloquent\Model

I need to mock Laravel's Eloquent\Model with Mockery and it is kind of tricky because it uses static methods. I solved this issue with the following code but I wonder if there is a better/smarter way ...
1
vote
1answer
297 views

Class doesn't accepts mocked dependencies when running phpunit

I'm mocking two dependencies in my test which I pass to the class constructor of the class AlertsMessageBag. But php throws errors that I'm passing the wrong depedencies (Mockery\Mock). This happens ...
0
votes
1answer
67 views

Why no return value from function named 'link_to' with PHPUnit in Laravel?

Currently following a Laravel 4 book on writing tests, the following returns no output from PHPUnit if the function is named link_to(), but does return the result if it is named something else like ...
0
votes
1answer
61 views

Installing phpunit to a Laravel 4 site

When reading through a Laravel book, why does the author recommend installing phpunit as a require-dev in the composer.json file? composer.json { "require": { "laravel/framework": ...
0
votes
1answer
70 views

Can't perform a Laravel 4 action/route test more than once

I'm running into a Laravel 4 testing issue: An action/route test can only be run once, and it has to be the first test run. Any subsequent action/route test will fail with an exception before the ...
1
vote
1answer
365 views

Laravel 4 Repository Validation and Tests

I am trying to write a testable Laravel 4 application. In Taylor Otwells book on Laravel https://leanpub.com/laravel he writes that we should consider creating a UserValidator class within a ...
2
votes
1answer
446 views

Laravel Unit Testing - Run All Tests

I'm pretty new to both Laravel and PHPUnit, and I'm using Laravel 4 on Ubuntu 12.04. When I run phpunit from my project's home directory, it runs the ExampleTest.php test that comes with Laravel. I ...
0
votes
1answer
344 views

laravel testable store method with validation in basemodel

I am trying to test creating a follower, however, because I am calling Auth::user()->id I get the error "Trying to get property of non-object". At the moment I have been building an input array and ...
6
votes
2answers
447 views

Laravel & PHPUnit : allow process isolation to prevent Mysql Too many connections error

Since four months we build a complex web app with Laravel 4 with a good unit test coverage. Now we have 159 tests and 592 assertions to prevent against regression and allow us to easily refactor our ...
1
vote
1answer
566 views

Laravel 4 PHPUnit Sqlite Database, delete items before every test

I have a Laravel 4 application with sqlite db configured for testing. I am working in a workbench package I have a problem testing my models in a PHPUnit Test, because i defined some unique ...
1
vote
1answer
56 views

Making sure expected methods are callable

So I was testing a class and expecting it to call a method from a dependency: $userMock = Mockery::mock('User'); $userMock->shouldReceive('updateTimestamps')->once()->andReturn($userMock); ...
0
votes
0answers
153 views

Laravel 4 - blank inputs in a unit test

I have the following test in laravel: $this->post('/login/verify', array( 'name' => '', 'password' => '' )); $this->assertRedirectedTo('/login'); ...
1
vote
1answer
276 views

Laravel 4 controller tests - ErrorException after too many $this->call() - why?

I'd greatly appreciate some help regarding a Laravel 4 issue I'm experiencing. I'm testing controller routes, specifically a controller that is responsible for routing responses for a questionnaire. ...
0
votes
0answers
261 views

Laravel 4 Model Events don't work with PHPUnit

I build a model side validation in Laravel 4 with the creating Model Event : class User extends Eloquent { public function isValid() { return Validator::make($this->toArray(), ...
0
votes
1answer
484 views

Laravel facade class not found when mocked in a unit test

I might be missing something here but I have a very simple helper class that creates a directory: // Helper class <?php namespace MyApp\Helpers; use User; use File; class ...
0
votes
1answer
174 views

ANSWERED: How to write a unit test in PHPUnit

I'm writing a simple library I can reuse in some of my projects. At the moment its just going to swap some 'dumb' characters for their smart equivalent. Anyway, I installed a fresh instance of laravel ...
0
votes
1answer
533 views

Eloquent class not found when testing new models

I'm trying to test my eloquent models but my tests keep failing with "Class 'Eloquent' not found" errors. If I add a route that uses my eloquent model and simply prints some of the information stored ...
2
votes
3answers
826 views

Mocking Eloquent Models with find()

I am trying to Mock Eloquent Model with Mockery. Model is being injected in Controller via __construct(Post $model){$this->model=$model}. Now I am calling the find() function in controller $post = ...
0
votes
1answer
254 views

Artisan::call() in Test failing

I need to clean the database before running the tests or I get weird errors about duplicate information. in my PostTest.php file I create a setup method public function setUp() { ...
0
votes
2answers
430 views

Laravel 4 Unit Testing: “headers already sent” error when injecting mocks using App::instance

I'm new to Laravel and the concept of the IoC. I was following the great tutorials over a Nettuts (http://net.tutsplus.com/tutorials/php/testing-laravel-controllers/) and was able to successful test ...

15 30 50 per page