« first day (1660 days earlier)      last day (3291 days later) » 
00:00 - 16:0016:00 - 00:00

12:06 AM
@James tbh, the CSV processing functions suck. It might be a good idea to just use a separate library like packagist.org/packages/league/csv - I haven't used it, but it probably isn't as buggy as the built-in stuff.
 
@Danack tell me about it - it's frustrating as correct code randomly works in some instances, and then it completely fails in others. Thanks for the link, I think I'll try some ext libs out
 
 
1 hour later…
1:15 AM
@LeviMorrison Random question related to Reddit - do you know of any proper studies of how people actually read code?
 
@Danack I believe I've read one before.
Code has kind of two ways its read, just like books:
skimmed and read
skim is more like 'scan'
I was hoping he would say something along the lines of "it's difficult to see where the body stops with a ~> compared to an explicit function() use() {}.
 
Yeah....That's my belief as well (with the added factoid that people can only scan in one direction at once), but it would be nice to back that up with a reference some times.
 
Hey alll, can some one help me out with an issue I am having: stackoverflow.com/questions/30006250/… I get this error: Class 'doctrine.orm.validator.unique' not found and I thought everything was registered properly ...
 
1:40 AM
hey guys, is there a "de-facto" template engine for php?
 
2:00 AM
> Is this a real vulnerability?

Yes. Didn't you see that it has a name, logo, and website? These are all signs of a critical Internet-ending vulnerability that you should start freaking out about.
2
 
 
4 hours later…
6:25 AM
@James sure.
 
 
4 hours later…
Anonymous
10:04 AM
moarning
 
11:59 AM
Mornign
 
Anonymous
morping
 
Anonymous
> password3
 
Anonymous
this one has to be the worst
 
Hello, I am still trying to work out how to run php unit. I have installed it via composer and created my first test in /test/app/controller/welcomeTest.php
my index.php in the root folder calls my autoloader. How do I run a test as I have tried.

phpunit tests/app/controllers/welcomeTest.php

and I doesn't work but is that because it is not calling the auto loader?
My cmd screen says phpunit not reconised.
or do i run it from the php unit directory.
 
Anonymous
just make sure your test files calls the phpunit autoloader correctly.
 
If you just do phpunit yourtest it would only do that. Try to run that test
Do you have a testsuite?
 
12:28 PM
no
 
Or a config file?
 
I just manages to run it from the phpunit directory and its thrown an error saying....
 
Anonymous
welcomeTest{} is not a testsuite?
 
dd :P
 
12:29 PM
Fatal error: Class 'PHPUint_Framework_TestCase' not found in C:\wamp\www\2015\Ap
ril\interview\tests\app\controllers\welcomeTest.php on line 3
 
If you don't have a config that handles it for you and you just want to run that thing run it with the bootstrap flag
--bootstrap your index file
Assuming you handle autoloading or at least loading the files in there
 
so like, phpunit --bootstrap index.php /test.....
 
yes
 
C:\wamp\www\2015\April\interview\vendor\bin>phpunit --bootstrap ../../index.php
../../tests/app/controllers/welcomeTest.php
 
You not from the phpunit dir
Oh, you use relative path
Yeah should work I think
 
12:33 PM
came back with this
a
<h1>Please install via composer.json</h1><p>Install Composer instructions: <a hr
ef='https://getcomposer.org/doc/00-intro.md#globally'>https://getcomposer.org/do
c/00-intro.md#globally</a></p><p>Once composer is installed navigate to the work
ing directory in your terminal/command promt and enter 'composer install'</p>
 
Never had that before sorry
 
ahh thats my script
lol
 
@PeeHaa I have tried it now using the vendor autoloader and thats not working either can you see what i have done wrong. ->> pastie.org/10126557
 
@StephenWolfe You should start using proper relative paths to the currect dir using __DIR__
So require_once __DIR__ . '/../../../vendor/autoload.php';
 
12:43 PM
@PeeHaa never used that before, seen it though
 
It's basically a saner way of doing relative refernces instead of relying / guessing what PHP's cwd is
 
@PeeHaa still the same number of ../ ? though
What do you mean by PHP's Cwd
 
Yes
CurrentWorkingDir
 
ahh okay
@PeeHaa what did you think to my error?
 
12:47 PM
Still saying it cant find the file
 
@PeeHaa I think its correct, imgur.com/3chKaLE can you see ?
 
Sorry for being really bad at this,
Always though unit testing would be easy.
bloody pain trying to work out how to set it up.
 
Yeah looks correct. But why don't you let your bootstrap file handle that?
 
12:51 PM
I tried that and it did the same
well it couldnt find the autoload so it throw an error
 
You will make it yourself a lot easier if you just set it up correctly.
Look here and here
 
@PeeHaa can you talk me though how I would use this class and XML file.
 
Give me 10 minutes so I can burninate a tag and I will have time for you
 
12:55 PM
Okay,
thanks
 
@PeeHaa what are all the questions for?
 
1:06 PM
Ahh so your just doing some moderating
 
Yeah
/helpdesk dump (8 more needs to be burninated)
So @StephenWolfe
 
@PeeHaa i have made a git repo github.com/stevewolfe555/smvc
 
Let me see
 
just so if you can help me u can see what im doing
 
ok for starters: what is that phpunit phar doing in your project root?
 
1:11 PM
:/
I dont know it was part of the install I thought.
Maybe I downloaded that trying to so something else.
 
Nope shouldn't be
Because you have
 
delete?
 
"require-dev": {
    "phpunit/phpunit": "4.6.*"
},
@StephenWolfe Yes delete it
 
When running composer update it already installs it in your vendor dir
Secondly (not really related to your problem, but worth mentioning):
 
1:12 PM
Yeah i got that bit.
 
You should not commit your vendor dir. The project should just be cloned by users and they should do composer install
Which is somewhat the same as composer update only it uses pinned (as defined in your composer.lock file) versions of the dependencies
 
Ahh I thought that. Is there a way to stop it getting uploaded with out unchecking it each time?
So when someone else installs my project... they run install
because i had to run update.
 
Yes you can ignore files and directories in git using a .gitignore file
 
oh yes i have one of them
do I just put /vendor
 
However since you have already commited it you should first remove it from it from git
 
1:16 PM
in it
 
I just use vendor/
 
how do i remove it
 
git rm -r --cached vendor
After that commit and push
 
awsome
Done!
 
Now back to your actual phpunit question :)
 
1:20 PM
:D
 
First thing you want to do is add a phpunit config file in your project root
 
okay
how do i configure it.
 
This allows you to specify where your tests are, what files to ignore (e.g. exception for code coverage)
 
     bootstrap="test/bootstrap.php"
is that my index.php
 
morning
 
1:23 PM
Nope. You should not use that file directly. Because you want to unit test specific and isolated parts. Your index.php loads your enitre application
@Leri Morning o/
You should create a dedicated bootstrap file for your tests
 
@PeeHaa so do i need to create a bootstrap.
ahh
 
In my test directory I have a dedicated bootstrap file which sets the timezone (because derick is an asshole) and sets up an autoloader to load all classes github.com/PeeHaa/Minifine/blob/master/test/bootstrap.php
I use composer's autoloader, but you could also create a simple spl autoloader yourself
 
ahh test data is wrong
 
Yeah. You don't need that for now I think. I just use that to provide test data
 
I was going to put my tests in the same directory format as my application
e.g. app/controllers/
 
1:27 PM
I do the same.
/test/Unit/Minifier/Css contains the tests for /src/Minifier/Css
 
okay great so i have adjusted that, now I need to reflect that in the xml
 
Correct
 
@PeeHaa
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
<exclude>
<file>src/Minifine/InvalidTypeException.php</file>
</exclude>
</whitelist>
</filter>

what does this do>?
 
It only need to run tests for .php files. and I have excluded the exception, because there is nothing in there to test. Otherwise my code coverage would tell me I forgot to test a class
 
So do i need something like that?
 
1:31 PM
Eventually it would be nice if you can see the code coverage, but lets first get this working
 
okay
I have uploaded my changes
 
k one moment. Let me check your test file to see whether it is correct
 
Do you use an autoloader in your project?
 
@PeeHaa Well its smiplemvc and it does have one
... just I am not sure how to use them,
well other than specifying what files are required
 
1:35 PM
Looks like you are using composer's:
"autoload": {
    "psr-4": {"": "app/"}
},
 
@PeeHaa yeah so its only loading in the packages installed via composer correct?
 
@StephenWolfe Nope. Also your application is autoloading when using it
Although on nix it would fail, because of case sensitivity
 
class Welcome -> welcome.php
Should be
class Welcome -> Welcome.php
 
ahh I thought that...
Clasess should be Caps yeah?
 
1:38 PM
@StephenWolfe Linux / unix and the likes are case sensitive
 
PSR 1
 
@StephenWolfe Yes. UpperCamelCase
 
and models should be camelCase
 
s/models/methods
Also try to add your first test case now. Something simple like:
 
how do i update git to recognise the change in capps for file names?
 
1:42 PM
@StephenWolfe Oh god. Your on windows?
 
:(
yes
 
I always just rename the files to something different like: welcome.php -> welcome.phpx -> Welcome.php
 
@PeeHaa do u use linux?
 
Dunno whether there is a better way
@StephenWolfe And windows
 
@PeeHaa can i just use that delete command on the two files i used
then push the files again
 
1:44 PM
errr yeah that might also work. Try it
/**
 * @covers controllers\Welcome::__construct
 */
public function testConstructor(){
    $this->assertTrue(true);
}
^ first test case
 
yes
 
if thats right how do i run it
 
vendor/bin/phpunit
from the project root
Or vendor/bin/phpunit --coverage-text if you have xdebug installed and want code coverage report
 
so i am in the project route....
what do i type? phpunit vendor/bin/phpunit
 
1:51 PM
vendor/bin/phpunit
 
that doesnt work
 
Doesn't work how?
 
command not found
do i not need to tell it to run phpunit?
 
Oh sorry. Wrong slashes
vendor\bin\phpunit
 
okay that has given me the phpunit default output
like the version etc
 
1:54 PM
Don't you see the tests being run?
 
nope
dont we need to tell it what file to run
 
It should use the config file in the root
ah
 
phpunit.xml.dist.xml -> phpunit.xml.dist
 
Anonymous
still about unit testing?
 
1:56 PM
C:\wamp\www\2015\April\interview>vendor\bin\phpunit
PHPUnit 4.6.6 by Sebastian Bergmann and contributors.

Cannot open file "C:\wamp\www\2015\April\interview\test/bootstrap.php".
 
@StephenWolfe Is the path correct?
 
nope
:D
 
:P
 
Anonymous
interview\test/bootstrap.php seems fishy
 
@samaYo That's just windows vs linux path separator
 
1:57 PM
okay corrected the path
back to this error
C:\wamp\www\2015\April\interview>vendor\bin\phpunit
PHPUnit 4.6.6 by Sebastian Bergmann and contributors.

Cannot open file "C:\wamp\www\2015\April\interview\test/bootstrap.php".
soz
Fatal error: Class 'PHPUint_Framework_TestCase' not found in C:\wamp\www\2015\Ap
ril\interview\tests\app\controllers\WelcomeTest.php on line 3
 
You are an idiot :P
 
unit*
:(
 
:D
 
i am dyslexic
 
Anonymous
lol I just saw that
 
1:59 PM
Haha epic it ran!
 
\o/
 
lol all this time it was that
 
Anonymous
@StephenWolfe use an IDE next time
 
At least you have a decent phpunit set up now :)
 
@samaYo like?
@PeeHaa I am just trying to learn some basic unit testing first
sorry at @samaYo
 
2:01 PM
@StephenWolfe Yeah you can now easily add tests and run them all
 
Anonymous
like SublimeText It will tell you, if you are an idiot or not @StephenWolfe
 
Also you will find out that your project will make it a pain to properly test
 
@samaYo I am using sublime
 
Which is another win
 
@PeeHaa what do you mean my project will make it a pain?
 
2:02 PM
@samaYo sublime is not a IDE
 
Anonymous
@StephenWolfe doesn't it tell you if you write a non-existing class?
 
@StephenWolfe When you want to test your units you need to be able to isolate the part you want to put under test. So that you only test that specific thing and nothig else
 
@samaYo no
@PeeHaa and how would I isolate it?
 
A specific example:
 
Anonymous
I think it does. Check with the auto-suggest drop down
 
2:06 PM
You are tightly coupling the actual database to that class here
 
@samaYo I cant find it, my sytax mode is set to php and when I type it will suggest what i am trying to write
 
There is no way you can test now without a database
When unit testing your code you don't want to hit the database (unless that is what you are testing)
You want to use a mock instead so you can properly assert stuff without the overhead of a databse
 
@PeeHaa so whats the solution
 
Dependency injection
57
A: Use global variables in a class

PeeHaaThe correct way to solve this would be to inject the database handle into the other class (dependency injection): $db = new DB_MySQL("localhost", "root", "", "test"); // connect to the database include_once("pagi.php"); $pagination = new Paginator($db); $records = $pagination->get_records("SELE...

Different code same problem ^
Or if you are more of a video guy g-truc.net/post-0182.html
Stuff like that comes painfully clear once you start unit testing your code
@RonniSkansing o/
 
@PeeHaa okay you have lost me, but essentially your saying when I run my unit tests its running all of them at once and its hitting the database. What I want to do is run tests individually with out hitting the DB?
 
2:11 PM
Yes.
More simple example:
 
@PeeHaa so the config file we have atm is just running all the test files in that folder.
 
Yes, but that is ok, because it is fast
Lets say you want to unit test controllers\Welcome::index()
 
So you write a test case for that specific thing
However...
In there you are doing:
		View::rendertemplate('header', $data);
		View::render('welcome/welcome', $data);
		View::rendertemplate('footer', $data);
 
2:13 PM
So you are not just testing controllers\Welcome::index you are also testing View::rendertemplate, View::render and View::rendertemplate
 
okay
so would i need to change my test file
to just loads the controller
 
Nope. Your application is the culprit
There is no way to run controllers\Welcome::index without running all the other stuff
Because you have hardcoded it
 
But it has to run them...?
 
Yes but you can inject it instead. Let me setup a gist
/ see whether I can find an example
 
so can I just pass an option to the view file to tell it not to load them>?
 
2:16 PM
Nope
 
Anonymous
@PeeHaa how many red bulls did you have today?
 
I am on my second coffee
 
oow coffee > great idea
 
The first two are what you are doing
The latter two are the fix
Now in your test case you can create a mock using $mockView = $this->getMock('View'); and use that instead of your actual View class
That means you only test your isolated Welcome::index method
 
@PeeHaa I am trying really hard not to get lost here. are you saying I need to adjust the way my view class works?
 
2:23 PM
Yes
But more important just start writing tests now and the issues will become clear eventually :)
 
@PeeHaa but its part of the frame work.
 
@StephenWolfe You can achieve the same only written differently (using dependency injection instead of statics)
 
@PeeHaa so can I just change the way I write my tests or do i have to change the frame work
 
The latter
 
2:25 PM
You can unit test parts of the framework
The parts that are actually isolated
Looking for something that is properly isolated...
 
So where do I start?
 
This looks like it doesn't depend on anything else github.com/stevewolfe555/smvc/blob/master/app/helpers/…
I would suggest starting to add test cases for this
 
@PeeHaa they are helpers for the framework.
 
And a perfect starting point of writing tests for
 
@PeeHaa surely I only want to test what i have written?
 
Anonymous
2:29 PM
@PeeHaa could you also throw in a simple gist like that for a model? as in the true @tereško-esque definition of a model. I still can't get it after all this time.
 
Depends. It would be a good start
@samaYo I don't know what a model is and I never use something called a model in my application. I write classes which may contain business logic.
 
Well this application that I am making is just really basic its going to: display a list for DB, then have CRUD,
so I can test all of that?
 
Yes if you properly isolate the different parts you can
 
Anonymous
I mean what exactly does the model look like mvc frameworks.
 
@samaYo There is no such thing as a mvc framework in php
The sooner you realize there is no such thing as mvc the better and you can start writing proper code again
Separation of concerns are the keywords. Not pattern X
 
2:34 PM
Provide (pseudo) code that defines the classes and the components that use the classes. Explain the relationship between the classes and components.

Can anyone expand on this as to what it means
 
Anonymous
ah come on, aren't these already well-established facts? controllers, model, view ...
 
@samaYo Nope
 
I know psudo code
but what do they mean by components ?
 
Anonymous
Ok, forget it. it's fine.
 
Seems like they are asking about dependency injection?
 
2:36 PM
Hmm,
A software design patten, thats just when u write resuable code right?
 
@samaYo FWIW they are well established. It's just that people blurred the line once they started using MVC as a marketing badge instead of what it actually means
@StephenWolfe That can be one goal
 
2:53 PM
@samaYo model = all the code minus user interface/presentation layer code
 
Anonymous
@Gordon too vague. I was hoping something along the lines of .. model uses entities/data mappers/orm to get request from controllers to return back the data...
 
Anonymous
my question was, how exactly is this done the best way ...
 
@samaYo the Model is vague.
 
@samaYo There is NO SUCH THING AS MVC IN PHP
 
Anonymous
@Gordon which is why, I am asking for simple example. or in other words to un-vague it!!
 
3:02 PM
MVC is like a cancer for (PHP) developers. They stop thinking about a problem domain and try to mangle some broken pattern instead of solving an actual issue
/rant
 
@samaYo Whether you use Entities, Data Mappers, ORM and what not depends on the problems your model is supposed to solve. There is no rule that says you have to have all that. You can just as well have simple transaction scripts or table data gateways with table modules. whatever solves the problem.
There is no rule that says MVC has to have all of these: martinfowler.com/eaaCatalog
it just has to have whatever it needs
 
Anonymous
The problem is that you say, the model is a generic concept, open to interpretations and anyone can make a model on how they see it fit. But, once someone creates a model, then all hell breaks loose. People start to say, this and that is wrong.
 
@samaYo It's about modeling something / a process / a problem. It's not about hey this class maps my table 1:1
 
Anonymous
514
A: How should a model be structured in MVC?

tereško Disclaimer: the following is a description of how I understand MVC-like patterns in the context of PHP-based web applications. All the external links that are used in the content are there to explain terms and concepts, and not to imply my own credibility on the subject. The first thing that...

 
@samaYo well, you should still adhere to good coding practices. with regard to MVC the only thing that you can do wrong is putting presentation layer into the Model.
 
3:08 PM
BTW @Gordon do you still do talks?
 
@PeeHaa yes, but I missed the CfP for everything this year
@samaYo I still stand by my opinion that this is an ivory tower answer
 
Anonymous
@Gordon no, I am not mixing business logic with my controllers or presentation.
 
@samaYo so why would anyone complain then?
 
Anonymous
@Gordon because they have this super-different idea/definition about what a model is or should be, so I couldn't argue.
 
Anonymous
Hmm, maybe I will just produce an example someday, and it'll be easier to debate/point out the flaws then..
 
Anonymous
3:18 PM
I built an mvc framework about a year ago, using @PeeHaa's commentar project as a great example, sadly I could not see/find a model in it, so I killed the framework till I could understand the model part in depth.
 
Anonymous
sounds funny, but it's true.
 
Because there is no such thing as a model in it. It's a collection of classes of which some model the process and some are used for presenting data
 
@samaYo MVC doesn't say how your Model should look like. It's really just a small pattern that aims at separating user interface/presentation logic from the rest. It got a lot undue attention and nowadays people still think it's some big pattern. It's not. Controller handles input, View handles Output, Model does everything else. That's all.
@samaYo Stop worrying about how MVC should look like and start shipping code instead.
 
Anonymous
yeah, I know. It just bugs me to skip something, that's all.
 
Anonymous
anything against this idea for a model? codetuto.com/2013/07/creating-php-website-using-mvc-4.html
 
Anonymous
3:24 PM
It's ancient, but it also fine imho
 
@samaYo yes, it confuses terms. Model is a layer. This particular class is an ActiveRecord.
 
Anonymous
@Gordon What exactly does the term layer imply?
 
Anonymous
and thanks for the links.
 
@samaYo that it may contain multiple classes
 
Anonymous
But, multiple classes or not, if it returns what it's supposed to provide, why should it matter whether it is made of one class or 10 classes.
 
Anonymous
3:34 PM
aside for reasons of SoC
 
@samaYo it's not a physical thing
it's not a concrete artifact
it's more like a boundary
yes, it can have only one class, but it is not one class
 
Anonymous
hm, interesting. I will just give it more time and then it will come to me ... eventually. :)
 
ttj
3:52 PM
why does yeoman create thousands of subfolders?
 
@ttj Why don't you ask the yeoman people?
 
ttj
i don't know where they are
 
Anonymous
or the js people
 
@ttj I can tell you they are not here
 
ttj
okay thanks
 
3:54 PM
Neither in your public grocery store. Yet you don't go ask there :P
 
ttj
right. thanks anyway
 
Also WTF is a public grocery store??
/me has written too much code this weekend
 
@PeeHaa it's ok as long it's public final groceryStore()
 
:P
 
00:00 - 16:0016:00 - 00:00

« first day (1660 days earlier)      last day (3291 days later) »