Nette Pro / Magazine #1

by Honza Černý about a year ago in Nette

We Are Expanding

Our Czech mailing list community already counts more than 600 subscribers. It is a shame that we are not able to gauge the exact count of newcomers who decided to read this actual post. But I believe that this number is going to rise at least as fast as the Czech, local one.

Nette Framework

A new patch version of Nette Framework has just released. It brings a few novelties that may be found at https://forum.nette.org/…3-9-released. I cannot leave out, at least, one of them – it is now possible to turn off the Tracy by Debugger::$showBar = FALSE; The last stable versions (2.3.9, 2.2.12 and even 2.1.12) are fully compatible with PHP 7 and, as a bonus, version 2.3.9 is able to get use of PHP 7 features as argument type hints and a return type of a generated factory.

But this is not the end yet. There has also been proposed Nette 2.4 release plan; the subsequent issue of this newsletter is going to contain some more info about it.

Tracy Built Upon AJAX

David Kadera is currently working on some changes that I would like to mention. The functionality of Tracy is going to be enhanced with support for AJAX (and likely CLI also) – the first dose of code and tests are already online. You can review a working prototype at https://github.com/…ree/ajax-bar.

PhpStorm Plugins

The popular PhpStorm plugins have been updated – David Matějka submitted their new versions during February. Especially autocomplete feature in the NEON plugin works pretty well. David has also recoded a core of Nette Framework plugin that is no longer causing occasional deadlocks. And this is not the end – a new version of Latte plugin has also been released, which (besides of ordinary and n: macros) fully supports HTML, Emmet, JavaScript and CSS development.

These plugins are accessible through the JetBrains Plugin Repository (Neon, Nette and Latte). You might also want to support us by starring our corresponding GitHub repositories. Neon ★, Nette ★, Latte ★

#NetteFwPivo

More and more people are coming to our informal discussing event, so as a consequence, we are expanding to even more locations during the next month. A new Facebook page is about to be set that is going to work as a hub of organizing these events at even more places – e.g. it will be possible to involve cities as Vienna or Berlin.

Shirts

You can support our team by purchasing official Nette t-shirts from a recently launched online store. Also, when you are buying a t-shirt, don't forget to order some more Nette stickers; Unfortunately, out-of-Czech delivery is not currently supported. But anyway, in case of demand of any item, you can still contact me.

NettePro

A reveal of NettePro is coming soon. David Matějka has already coded a ticket support app and David Grudl is finishing a registration tool and a dashboard containing info provided to our partners. Last, my work is to hire people for a support team (Nette Support Commando – will be adjusted ;-) ).

In a Nutshell

Componette

Milan is constantly updating a new addons portal which is about to lose its beta tag soon. Test it and leave a feedback.

Nette\Object

A lifespan of this hangover tool is certainly heading to the end. A Newer version of Nette Framework will replace this object by Trait collection. You can already see it in production at Dibi and Texy projects.

Nextras ORM 2

Nextras community has released new major version of its new popular ORM newcomer. Change list may be accessed from here.

Nette Tester & PhpStorm

Jirka is currently working on a code integration, see the online repository.

To Conclude

You have just finished reading of the first official NettePro Newsletter. If you desire to leave some feedback or whether you miss some important info here, please contact me.

Honza Černý (it’s like John Black) hello@honzacerny.com


Nette Pro / Magazine #0

by Honza Černý about a year ago in Nette

We are starting something new

This article is a shortened translation of a Czech e-mail magazine. Honza started with writing some news from our community and foundation. Because we want to talk to you, no matter where you are, we have also turned this e-mail magazine into a blog post. We are planning a new article delivery in every 2–3 weeks. However, a brief delay might occur depending on a translation speed. If you'd like to help us with a content and/or corrections, contact Honza for more information. We are open for any help.

#NetteFwPivo

This Twitter hashtag stands for small repeated events and casual community meetings. An English equivalent, #NetteFwBeer, will also be used. These casual meetings take place every second Wednesday in a month. If you'd like to set up your own local community event, just create an event at http://eventle.com/(or elsewhere) and promote it on a Nette forum. We want the community to grow and this is a one of the ways how we are able to make it happen.

“Poslední sobota”

“Poslední sobota”, which stands for Last Saturday, is a bigger happening that is taking place on the last Saturday of every month. Unfortunately, it is only Czech event (so far). However, we are planning to spread the event to even more locations (there is still plenty of places to visit) to gather and keep all the local Nette comunities together. We’d also love to visit places beyond Czech borders to come up with some new amazing English talks. If you want to land a hand, don’t hesitate to contact us. Initially, we’d like to expand to Germany, Poland, Austria and Slovakia, but our door is certainly open to many other countries as well. :)

Addons portal

Milan (Felix) released a new version of a next generation addons portal. This is the place where you can find a lot of addons for your Nette applications. It’s still in beta, but we are working hard to make it as seamless as possible. As soon as all the addons are available and latest minor visual improvements are finished, we will place the new portal whereas the old one is going to serve as an example Nette application on GitHub. So, if you have any ideas or bug reports, please open an issue on GitHub or just tell us on Gitter:gitter.im/componette/componette

T-shirts!

We are planning to launch a Nette Pro merchandise e-shop. The e-shop is comming out in late February. First offer will cover (official) t-shirts only, but some additional products may be coming soon. Any gained profits will be used to buy either new or existing equipment capable of recording our events to make them accessible to even broader audience.

Shorts

Tester

New version of a Tester testing tool has been released. Milo wrote a blog post describing new features and changes involved. You can find it here: https://blog.nette.org/…tester-1-7-0.

FTP deployment

If you are using FTP as a software deployment tool, you’ll definitely appreciate a new version of ftp-deployment tool that has been currently released by David. You can find more about the 2.3 release, including some news, on GitHub release page at https://github.com/…ses/tag/v2.3.

Lean Mapper

ORM Dibi-based database layer, originally developed by Vojta (Tharos), will be taken over by Mirek (Castamir). He’s been using Lean Mapper for a long time and has a lot of new ideas and improvements to implement.

For the end

Next magazine edition will come shortly. This article is covering only a small portion of all the changes planned. Finally, as a sneak peek, we are working on a new navigation through nette.org portal. In upcoming edition, there will be information about a lot of new stuff, including changes in codebase and, of course, Nette Pro.

If you’d like to help us with further improvements, just contact Honza.


Changes in Nette Tester 1.7.0

by Miloslav Hůla about a year ago in Tester

Nette Tester 1.7.0 is out. I'll summarize the changes.

HtmlGenerator, which generates HTML code coverage report, now counts lines from not evaluated files as not covered. The only impact is, that you can see lower percentual coverage in report. Imagine the situation, that you have two source files (same lenght for simplification), but only one of them is loaded by tests. You got 100% coverage before, now you get only 50%.

If you are using TestCase test methods with @dataProvider, data provider method can return Traversable now. As a consequence of this, you can use generator (yield). It is handy for lazy data loading, for example from remote API. Short example:

class RemoteAPITest extends Tester\TestCase
{
    /** @dataProvider getRemoteData */
    public function testMe($arg)
    {
        Assert::same(..., $arg);
    }

    public function getRemoteData()
    {
        foreach ($this->remoteService->cases() as $case) {
            yield [$case];
        }
    }
}

(new RemoteAPITest)->run();

Few changes happend in Dumper class. There is a object hash among the dumps. It helps to recognize a dumped object identity.

# Before
(object) array()
(object) array()
(object) array()

# Now
(object) /* #f231 */ array()
(object) /* #1550 */ array()
(object) /* #f231 */ array()

Dumper::dumpException() shows line of source code beside an Assert call in a stack trace.

# Before
Failed: 27 should be 25

in tests/Utils/Strings.phpt(23) Tester\Assert::same()
in Utils/tests/bootstrap.php(39) {closure}()
in tests/Utils/Strings.phpt(32) test()

# Now
Failed: 27 should be 25

in tests/Utils/Strings.phpt(23) Tester\Assert::same(25, Strings::indexOf($foo, '1'));
in Utils/tests/bootstrap.php(39) {closure}()
in tests/Utils/Strings.phpt(32) test()

Next change is related to @dataProvider. You could use the INI file path before, now you can use PHP script as a data provider. You have to return array or Traversable from it.

# dataprovider.php
return json_decode(__FILE__ . '/data.json');

# or
return new DirectoryIterator(__DIR__ . '/data-files');

# or just
return [
    'one' => ['a', 'b', 'c'],
    'two' => ['d', 'e', 'f'],
];

Next two small changes. Environment variable term = xterm-256color enables color printing. And FileMock now supports unlink()ing.

And one big change as the last. Tester now supports PHPDBG SAPI with PHP 7.0.0 or newer. The biggest impact of it targets code coverage. PHPDBG offers mechanism to collect information about executed lines of source code. By the other words, it can collect code coverage statistics. It is faster alternative to Xdebug which is not needed with PHPDBG. Usage is simple:

vendor/bin/tester -p /path/to/phpdbg --coverage coverage.html --coverage-src src

Some plans on the end. Tester supports PHP 5.3 now. We agreed that we will wait two or three weeks after 1.7.0 release and we will skip to 5.4 at least. I belive, that Tester 1.7.0 is good enough for PHP 5.3 projects. But if you are against, leave us a comment with arguments.

Many thanks to volunteers which contributed! This relase is actually their work. Check out the changes.

Tester's documentation is up to date.


Changes in Nette Tester 1.6.0

by Miloslav Hůla about a year ago in Tester

Nette Tester 1.6.0 is out. Let me summarize the changes.

New optional parameter $description has been added to almost all Assert methods. It works as an error message prefix when an assertion fails. It is handy in situations where the error message is not self-describing enough. For example, in a loop with assertion:

foreach ($model->getUsers() as $user) {
    Assert::true($user->isActive(), "User $user->name");
}
# Before 1.6.0 you got
Failed: FALSE should be TRUE

# Now you get
Failed: User sandokan: FALSE should be TRUE

Next change takes place in the Assert class too. A new assertion Assert::noError($callable) is suited to test snippets of code when there is no other assertion. It checks that $callable function does not generate any PHP notice/warning/error or exception. For example:

use Tester\Assert;

require __DIR__ . '/bootstrap.php';

Assert::noError(function () {
    # Checks that there is no error or exception
    $o = new Object;
    $o->doSomething();
});

Before 1.6.0 you could not wrap code into noError() and you had to make a workaround to prevent Error: This test forgets to execute an assertion message.

Next changes target the TestCase.

The @throws assertion is applied to testMethods() only, not to setUp() nor tearDown(). For example, if you had a testMethod() annoted by @throws \Exception, the method didn't throw an exception but tearDown() did, the test (probably wrongly) succeeded. Now, any exception thrown by setUp() or tearDown() is considered as test fail.

Another improvement is that the TestCase::tearDown() is called even when error is generated in a test method.

One small thing remains. Closures and anonymous classes dumping has been improved. You can find file and line info in dumps.

If you are interested in details, you can compare 1.5.0 and 1.6.0 version.


Changes in Nette Tester 1.5.0

by Miloslav Hůla 2 years ago in Tester

The Nette Tester 1.5.0 has been released last week. It's a small release and here I bring news.

Compatibility with PHP 7 has been improved. Tester works with PHP 7 well and now it supports Throwable interface. So all PHP 7 exceptions are printed and dumped correctly. No more problems are known, if you hit some, open an issue please.

The test runner (vendor/bin/tester) now prints PHP startup errors. It may disclose problem with PHP extensions loading.

Next new feature is internal thing for now. The Job instance, which represents one PHP process, now captures stderr output. It's internal, because you cannot use it for assertion yet. Stderr capturing has been discussed a long time ago. It's because this part of PHP (capturing more descriptors then one) is very buggy on Windows. With new PHP versions it looks better and better.

And that's all. As I said, a small release. Some tiny bugs in CloverXMLGenerator, Assert::match() and DomQuery::css2xpath() have been fixed. You can check the whole changelog for more information.

I have one bonus for you which I want to write in a bit more detail. It's about using Tester in a non common way.

Tester is available as a single PHAR file. It can be used in a dual way. The first one is as a library code source. You require PHAR file. Let's write two simple test files quick-1.phpt:

require __DIR__ . '/tester.phar';

Tester\Assert::true(TRUE);

and quick-2.phpt:

require __DIR__ . '/tester.phar';

Tester\Assert::true(FALSE);

Of course, you can run them as ordinary PHP scripts,

php quick-1.phpt
php quick-2.phpt

But with the Tester PHAR duality, you can simultaneously use tester.phar as a test runner:

php tester.phar *.phpt

One file, two purposes. It brings new workflow possibilities for a quick prototyping. You don't need a composer.json. You don't need an unpacked Tester code. Just download one file, include it and run…