At work we have an application built with php (codeigniter) and lots of jquery, don't ask :)
It's not a modern app, is a classical MVC PHP app. Would it be possible to integrate cypress.io with as less changes to the current estructure?
My idea was to install cypress.io in a separate folder and run the tests from there
is it a feasible solution?
Yes - you can test any web application with cypress.io.
I have done exactly as you describe.
How? - You can
add a folder to your existing source control,
run your development web-server as you normally would,
set the baseUrl to your development server (e.g. http://localhost:8080/),
write some tests & assertions that use your existing markup to find buttons, text etc,
and run cypress to test your app.
Take a look at "getting started" in the docs
You might also want to look at asdf-vm now that you will have node & php
Related
I'm relatively new to practical web development, so I apologize if the question is stupid. The crux of the problem: I only want to use Vue on the front end of the site, and on the back I am using a PHP framework (or not a framework, it doesn't matter). Connecting Vue to every page via a CDN seems to be wrong to me. I didn't quite understand how the CLI works, does it generate some kind of static files (like a compiler), or does it definitely need Node? And did I understand correctly that I can't use things like Vuex and vue-router without node.js? Thank you in advance!
VueJS and vue-router are totally independent JavaScript framework and router, you do not need NodeJs to use them, you might get confused after using npm but npm is just a package manager, using it is a matter of choice.
The ClI or currently #vue/cli is just a command line that you can use to create new projects and control them, run them etc, using it isn't required when using vue trough a CDN.
About PHP:
There are a lot of ways to use VueJs in PHP but the most convenient one would be creating a PHP API in the back-end and a normal Vue and Axios app in the front-end, this approach is the one you should get used too because its easily implemented in other languages and even PHP frameworks, for example WordPress.
I need help from you NodeJS ninjas. I am starting to learn it, after doing a good amount of LAMP stuff. I have written several systems in Apache/PHP/MySQL for a small corporate intranet (including things like a ticket system, employee scheduling, production reports, financial reports, etc).
So, in LAMP world, I start the Apache and MySQL engine. Then people go to their browsers, type the server IP and browse the different systems I've written for them based on the folder in htdocs.
I am trying to think what the equivalent would be in a set up with NodeJS, Express using the MVC model (something I am also new to). Two main questions:
Since I have several systems (employee scheduling, financial
reports, etc), would each one of these have their own middleware for managing, with their middleware rules and all that? or would they all run under just a main thread? (load balancing is another thing that came up).
What would the folder layout be? XAMPP had the htdocs folder and the folder structure was whatever I wanted.
From what I've seen in most tutorials, an option for a folder layout is:
-app
-- controllers
-- models
-- routes
-- views
-config
-- env
-node_modules
-public (I imagine the systems I implement would be on here?)
-server.js
Thank you for your help, I am still a complete noob, but I am excited to get into this.
I come from LAMP stack word and moved to nodeJS 2 years ago. A lot changed since then.
Things you need to know for nodeJS vs PHP :
nodeJS runs under google's JavaScript V8 engine.
nodeJS is ingle-threaded. PHP is multi-thread. That means any modification to a global variable, if there's any, is seen by all the connected users.
nodeJS with express alone is not MVC since MVC is a architectural pattern. You can if you want create folders to define a MVC pattern or hMVC pattern (depending on your needs). A bigger frameworks called SAILS does native MVC for you.
to start a nodeJS project, you have to cli node yourApp.js. That said, there is a better way to start a project using a script placed inside package.json managed by npm or using other npm package such as nodemon. There is no specific folder to start a project like PHP since PHP is managed by Apache and Apache is configured to have a specific folder for html docs.
Other things to add :
Javascript uses EcmaScript as scripting language. The version 6 of ES was finalised in summer 2015, and all browsers still doesn't native take it in charge. Since nodejs uses google's v8 engine, it's still based on ES5.1 or experimental ES6 with --hamrony flag calling node in cli. Since node5 many ES6 features are implemented but still not all are.
NodeJS is asynchronous, and async call are HARD to learn when you come from php word. You will need a lot of practices. I suggest you go read module pattern and revealing pattern.
I hope I have answered you'r questions
Title says it all really. The only thing I'd like to add is to say that after initial look at the paid versions of Zend Server, it looks like in terms of cost, I would be losing the advantages of not developing a web/cloud application on Microsoft's expensive Azure platform if I did choose to go with Zend. I like the look of the Zend Framework though and am considering using it on an open source LAMP stack. Or should I go with Symfony / CakePHP on LAMP to keep costs down?
The answer to your (actual, answerable) question is: Yes.
The framework is just a bunch of libraries (just like all frameworks); and you do the following:
Go to the download page.
Register (its free), and then download "Zend Framework Full Package".
Make sure the files are available to your application, by placing them in a directory to which the user that will execute your scripts (it is normally the same user that run the webserver, for example www-data).
Follow the get starting guide.
If you like build tools, you can also use composer to automatically download ZF2 for you, by following the instructions on this page.
I asked a question here on automated deployment of automatically deploying java code.
Our back-end Java API is accessed by a PHP web app. It would be nice to be able to automatically deploy this web app (along with static files like CSS, JS and images) to our web server while performing automatic testing on PHP code. Is there something similar to this for PHP?
I also wonder if as part of this automated testing you can check that each actual page loads without a fatal error. I am sure I read about a google project which allows you to write page tests e.g. click on link a, go to page b etc etc.
Thanks
You may want to look into using Phing for deployment which has features that allow testing with PHPUnit and/or SimpleTest
Maybe this question handling deployment strategies can help you.
Additionally, but maybe gone too far, tools like cruise control may help you to apply continuous integration, too.
PHPUnit with ant was my way to go for automated testing, which could be a vaild option for you, too since you're obviously using some java already :)
Since you're working with Java, you might consider using Hudson (also mentioned in your other question), which has the ability to execute build tasks consisting of several 'steps' One step step could be unit testing your Java App, another unit testing a PHP app, yet another deployinhg Java app, and another deploying a PHP app (and you could add some more ;P )
It has a Maven plugin, so you could actually use your existing Maven scripts.
I'm curious to see how other developers go about testing their web sites. PHP specifically in my case, but this probably spans multiple languages. I've been working on a site for over a year now, and I'd really like to automate a lot of the regression testing I do between versions.
This specific site is in CodeIgniter, so I have some tests for my models. I'd like to move beyond just testing those though. However, this is an issue even non-MVC developers have had to tackle I'm sure.
Edit: I think the functionality that would satisfy a lot of my test desires is the ability to assert that paramters have a specific value at the end of the script processing. In my case a lot of logic is in the controller, and that's the main area I'd like to test.
For actual unit testing without testing the UI, you should just test the functions in the model. Most of your functionality should be in there anyways.
You might want to have a look at Selenium for testing the UI of your site. It can record your actions and play them back, or you can edit the scripting directly.
(source: seleniumhq.org)
Have you tried Fitnesse ?
It helps on creating Acceptance tests. They are specially useful for websites, which doing this kind of tests are a pain.
There are a couple of videos from unclebob inside the webpage too. The good thing is that Fitnesse is not restricted for website testing, so your knowledge about using it can be used with other apps too.
The project I'm working on is a Desktop APP written in c++ that uses Fitnesse tests.
But if you meant unit testing the models (which I think you didn't), they can be create using the phpunit lib. I think the ZEND framework has a similar lib for that.
You might want to check out PHPUnit
http://www.phpunit.de/manual/current/en/
I have started using it on my PHP projects and it's very easy to work with and very powerful. In particular, learn and use mocks:
http://www.phpunit.de/manual/3.0/en/mock-objects.html
Mocking is especially important when unit testing applications that do database operations.
Take a look at TOAST. It's build specially for CodeIgniter. It uses CI infrastructure, so you can run all test tests via a browser and results are displayed back as a web page (HTML). It's very simple to use.
I suggest you test your Controllers as well. Testing model is ok, but model is just the DB storage. Controllers contain all the "business logic" and are the place where most things go wrong.
One of the best ideas I've heard of, as far as testing web apps go, was to create a script that would go over all the pages in the site and check them for differences from the previous scan, letting you accept changes and fix regressions.
Generally speaking, automatic testing of GUI applications (websites are GUI apps) is difficult and usually unnecessary. Unit tests work best with simple libraries.
I use Canoo WebTest. It is the best free web site unit test framework out there. It is entirely scriptable with XML and requires no browser so it can run from a build server.
We modified Waiter (Ruby). It plays back "scripts" of URLs and Form Filling to IE and we have added a script "command" to take a Screen Capture; the screen capture image is compared against a Known-Good-Image (i.e. a Master Image) and if that image is different it is logged (basically a Web page of such results is prepared) and "a human" does a review of the Master / Test image. Obviously there are two outcomes at that point - "The difference is intentional" or "There is an incorrect change". In the first instance the Master image is replaced with the New Image; in the second we go fix the bug, and the change will be included in the next test run