File: IntervalsTest.php

package info (click to toggle)
php-composer-semver 3.4.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 632 kB
  • sloc: php: 4,307; makefile: 6
file content (812 lines) | stat: -rw-r--r-- 34,770 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
<?php

/*
 * This file is part of composer/semver.
 *
 * (c) Composer <https://github.com/composer>
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 */

namespace Composer\Semver;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Composer\Semver\Constraint\ConstraintInterface;
use Composer\Semver\Constraint\MultiConstraint;
use Composer\Semver\Constraint\Constraint;
use Composer\Semver\Constraint\MatchNoneConstraint;
use Composer\Semver\Constraint\AnyDevConstraint;

class IntervalsTest extends TestCase
{
    const INTERVAL_ANY = '*/dev*';
    const INTERVAL_ANY_NODEV = '*';
    const INTERVAL_NONE = '';

    const COMPACT_NONE = '';

    /**
     * @dataProvider compactProvider
     * @param string $expected
     * @param array<string> $toCompact
     * @param bool $conjunctive
     */
    #[DataProvider('compactProvider')]
    public function testCompactConstraint($expected, $toCompact, $conjunctive)
    {
        $parser = new VersionParser;

        $parts = array();
        foreach ($toCompact as $part) {
            $parts[] = $parser->parseConstraints($part);
        }

        if ($expected === self::COMPACT_NONE) {
            $expected = new MatchNoneConstraint;
        } else {
            $expected = $parser->parseConstraints($expected);
        }

        $new = Intervals::compactConstraint(new MultiConstraint($parts, $conjunctive));
        $this->assertSame((string) $expected, (string) $new);
    }

    public static function compactProvider()
    {
        return array(
            'simple disjunctive multi' => array(
                '1.0 - 1.2 || ^1.5',
                array('1.0 - 1.2 || ^1.5', '1.8 - 1.9 || ^1.12'),
                false
            ),
            'simple conjunctive multi' => array(
                '1.8 - 1.9 || ^1.12',
                array('1.0 - 1.2 || ^1.5', '1.8 - 1.9 || ^1.12'),
                true
            ),
            'dev constraints propagate, disjunctive' => array(
                '1.8 - 1.9 || ^1.12 || dev-master || dev-foo',
                array('1.8 - 1.9 || ^1.12', 'dev-master', 'dev-foo'),
                false
            ),
            'dev constraints + numeric constraint, conjunctive results in match-none' => array(
                self::COMPACT_NONE,
                array('1.8 - 1.9 || ^1.12', 'dev-master', 'dev-foo'),
                true
            ),
            'conflicting numeric constraint, conjunctive results in match-none' => array(
                self::COMPACT_NONE,
                array('1.0', '2.0'),
                true
            ),
            'simple disjunctive results in same output' => array(
                '1.0 || 2.0',
                array('1.0', '2.0'),
                false
            ),
            'simple conjunctive results in same output' => array(
                '!= 1.2, != 1.6',
                array('!= 1.2', '!= 1.6'),
                true
            ),
            'simple conjunctive results in same output/2' => array(
                '!= 1.0, != 2.0',
                array('!= 1.0', '!= 2.0'),
                true
            ),
            'switches to conjunctive if more than != x is present' => array(
                '>1.5, != 2.0',
                array('!= 2.0', '> 1.5'),
                true
            ),
            'complex conjunctive with dev' => array(
                '!= 1.0, != 2.0',
                array('!= 1.0', '!= 2.0'),
                true
            ),
            'simple disjunctive with negation' => array(
                '!= 1.0',
                array('!= 1.0', '!= 1.0'),
                false
            ),
            'disjunctive with complex negation' => array(
                '*',
                array('!= 1.0', '!= 1.0', '!= dev-foo', '1.0.5.*'),
                false
            ),
            'conjunctive with complex negation' => array(
                '1.0.5.*',
                array('!= 1.0', '!= 1.0', '!= dev-foo', '1.0.5.*'),
                true
            ),
            'conjunctive with complex negation/2' => array(
                '>= 1.0-dev, != 1.2-stable, <2',
                array('!= 1.2', '!= dev-foo', '!= dev-bar', '1.*'),
                true
            ),
            'conjunctive with complex negation/3' => array(
                '!= 1.2, != dev-foo, != dev-bar',
                array('!= 1.2', '!= dev-foo', '!= dev-bar'),
                true
            ),
            'disjunctive with complex negation/3' => array(
                '*',
                array('!= 1.2', '!= dev-foo', '!= dev-bar'),
                false
            ),
            'conjunctive with complex negation/4' => array(
                '== dev-foo',
                array('!= 1.2', '== dev-foo', '!= dev-bar'),
                true
            ),
            'disjunctive with complex negation and dev ==' => array(
                '*',
                array('!= 1.0', '!= 1.0', '!= dev-foo', '1.0.5.*', '== dev-bla'),
                false
            ),
            'conjunctive with complex negation and dev ==' => array(
                'dev-bla',
                array('!= 1.0', '!= 1.0', '!= dev-foo', '== dev-bla'),
                true
            ),
            'complex conjunctive which can not match anything' => array(
                self::COMPACT_NONE,
                array('!= 1.0', '!= 1.0', '!= dev-foo', '1.0.5.*', '== dev-bla'),
                true
            ),
            'conjunctive with more than one dev negation' => array(
                '!= dev-master, != dev-foo',
                array('!= dev-master', '!= dev-foo'),
                true
            ),
            'conjunctive with mix of devs' => array(
                '== dev-foo',
                array('!= dev-master', '== dev-foo'),
                true
            ),
            'disjunctive with mix of devs' => array(
                '!= dev-master',
                array('!= dev-master', '== dev-foo'),
                false
            ),
            'conjunctive with more than one dev negation, and numeric constraint' => array(
                '> 5',
                array('!= dev-master', '!= dev-foo', '> 5'),
                true
            ),
            'conjunctive with more than one of the same dev negation' => array(
                '!= dev-foo',
                array('!= dev-foo', '!= dev-foo'),
                true
            ),
            'switches to conjunctive when excluding versions and complex' => array(
                '!= 3-stable, <5 || >=6, <9',
                array('!= 3, <5', '>=6, <9'),
                false
            ),
            'conjunctive with multiple numeric negations and a disjunctive exact match for dev versions' => array(
                '== dev-foo || == dev-bar',
                array('!= 1.0', '!= 2.0', '==dev-foo || ==dev-bar'),
                true,
            ),
        );
    }

    /**
     * @dataProvider intervalsProvider
     * @param array<mixed>|self::INTERVAL_* $expected
     * @param string $constraint
     */
    #[DataProvider('intervalsProvider')]
    public function testGetIntervals($expected, $constraint)
    {
        if (is_string($constraint)) {
            $parser = new VersionParser;
            $constraint = $parser->parseConstraints($constraint);
        }

        $result = Intervals::get($constraint);
        if (is_array($result)) {
            array_walk_recursive($result, function (&$c) {
                if ($c instanceof Interval) {
                    $c = array('start' => (string) $c->getStart(), 'end' => (string) $c->getEnd());
                }
            });
        }

        if ($expected === self::INTERVAL_ANY) {
            $expected = array('numeric' => array(
                array(
                    'start' => '>= 0.0.0.0-dev',
                    'end' => '< '.PHP_INT_MAX.'.0.0.0',
                ),
            ), 'branches' => Interval::anyDev());
        }

        if ($expected === self::INTERVAL_ANY_NODEV) {
            $expected = array('numeric' => array(
                array(
                    'start' => '>= 0.0.0.0-dev',
                    'end' => '< '.PHP_INT_MAX.'.0.0.0',
                ),
            ), 'branches' => Interval::noDev());
        }

        if ($expected === self::INTERVAL_NONE) {
            $expected = array('numeric' => array(), 'branches' => Interval::noDev());
        }

        $this->assertSame($expected, $result);
    }

    public static function intervalsProvider()
    {
        return array(
            'simple case' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 1.0.0.0-dev',
                        'end' => '< 2.0.0.0-dev',
                    ),
                ), 'branches' => Interval::noDev()),
                '^1.0'
            ),
            'simple case/2' => array(
                array('numeric' => array(
                    array(
                        'start' => '> 1.0.0.0',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => Interval::noDev()),
                '> 1.0'
            ),
            'intervals should be sorted' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 0.9.0.0-dev',
                        'end' => '< 1.0.0.0-dev',
                    ),
                    array(
                        'start' => '>= 1.2.3.0',
                        'end' => '<= 1.2.3.0',
                    ),
                    array(
                        'start' => '>= 1.3.4.0',
                        'end' => '<= 1.3.4.0',
                    ),
                    array(
                        'start' => '> 2.3.0.0',
                        'end' => '< 2.5.0.0-dev',
                    ),
                ), 'branches' => Interval::noDev()),
                '1.3.4 || 1.2.3 || >2.3,<2.5 || <1,>=0.9'
            ),
            'intervals should be sorted and consecutive ones merged' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 1.0.0.0-dev',
                        'end' => '< 2.0.0.0-dev',
                    ),
                    array(
                        'start' => '>= 3.0.0.0-dev',
                        'end' => '< 5.0.0.0-dev',
                    ),
                ), 'branches' => Interval::noDev()),
                '^4.0 || ^1.0 || ^3.0'
            ),
            'consecutive intervals should be merged even if one has no end' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 4.0.0.0-dev',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => Interval::noDev()),
                '^4.0 || >= 5'
            ),
            'consecutive intervals should be merged even if one has no start' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 0.0.0.0-dev',
                        'end' => '< 6.0.0.0-dev',
                    ),
                ), 'branches' => Interval::noDev()),
                '>= 5,< 6 || < 5'
            ),
            'consecutive intervals representing everything should become *' => array(
                self::INTERVAL_ANY_NODEV,
                '>= 5 || < 5'
            ),
            'intervals should be sorted and overlapping ones merged' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 1.1.0.0-dev',
                        'end' => '< 2.0.0.0-dev',
                    ),
                    array(
                        'start' => '>= 3.0.0.0-dev',
                        'end' => '< 5.0.0.0-dev',
                    ),
                ), 'branches' => Interval::noDev()),
                '^4.0 || ^1.1 || ^3.0 || ^1.2'
            ),
            'intervals should be sorted and overlapping ones merged/2' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 1.0.0.0-dev',
                        'end' => '< 1.5.0.0-dev',
                    ),
                ), 'branches' => Interval::noDev()),
                '1.2 - 1.4 || 1.0 - 1.3'
            ),
            'overlapping intervals should be merged even if the last has no end' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 4.0.0.0-dev',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => Interval::noDev()),
                '^4.0 || >= 4.5'
            ),
            'overlapping intervals should be merged even if the first has no start' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 0.0.0.0-dev',
                        'end' => '< 6.0.0.0-dev',
                    ),
                ), 'branches' => Interval::noDev()),
                '>= 5,< 6 || < 5.3'
            ),
            'overlapping intervals representing everything should become *' => array(
                self::INTERVAL_ANY_NODEV,
                '>= 5 || <= 5'
            ),
            'equal intervals should be merged' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 1.0.0.0-dev',
                        'end' => '< 2.0.0.0-dev',
                    ),
                ), 'branches' => Interval::noDev()),
                '^1.0 || ^1.0'
            ),
            'weird input order should still be a good result' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 0.0.0.0-dev',
                        'end' => '< 2.0.0.0-dev',
                    ),
                ), 'branches' => Interval::noDev()),
                '< 2.0 || < 1.2'
            ),
            'weird input order should still be a good result, matches everything' => array(
                self::INTERVAL_ANY_NODEV,
                '< 2.0 || >= 1'
            ),
            'weird input order should still be a good result, conjunctive' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 1.0.0.0-dev',
                        'end' => '< 2.0.0.0-dev',
                    ),
                ), 'branches' => Interval::noDev()),
                '< 2.0, >= 1'
            ),
            'conjunctive constraints result in no interval if conflicting' => array(
                self::INTERVAL_NONE,
                '^1.0, ^2.0'
            ),
            'conjunctive constraints result in no interval if conflicting/2' => array(
                self::INTERVAL_NONE,
                '^1.0, ^3.0'
            ),
            'conjunctive constraints result in no interval if conflicting/3' => array(
                self::INTERVAL_NONE,
                '== 1.0, != 1.0'
            ),
            'conjunctive constraints result in no interval if conflicting/4' => array(
                self::INTERVAL_NONE,
                '> 1.0, dev-master'
            ),
            'conjunctive constraints result in no branches interval if numeric is provided' => array(
                array('numeric' => array(
                    array(
                        'start' => '> 5.0.0.0',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => Interval::noDev()),
                '!= dev-master, != dev-foo, > 5'
            ),
            'conjunctive constraints result in no branches interval if numeric is provided, even if one matches dev*' => array(
                array('numeric' => array(
                    array(
                        'start' => '> 5.0.0.0',
                        'end' => '< 6.0.0.0',
                    ),
                    array(
                        'start' => '> 6.0.0.0',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => Interval::noDev()),
                '!= 6, > 5'
            ),
            'disjunctive constraints keeps branch intervals if numeric is provided' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 0.0.0.0-dev',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => array('names' => array('dev-master', 'dev-foo'), 'exclude' => true)),
                '!= dev-master, != dev-foo || > 5'
            ),
            'conjunctive constraints should be intersected' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 1.2.0.0-dev',
                        'end' => '< 2.0.0.0-dev',
                    ),
                ), 'branches' => Interval::noDev()),
                '^1.0, ^1.2'
            ),
            'conjunctive constraints should be intersected/2' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 1.5.0.0-dev',
                        'end' => '< 1.7.0.0-dev',
                    ),
                ), 'branches' => Interval::noDev()),
                '^1.0, ^1.2, 1.4 - 1.8, 1.5 - 1.6, 1.5 - 2'
            ),
            'conjunctive constraints should be intersected, not flattened by version parser' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 1.5.0.0-dev',
                        'end' => '< 1.7.0.0-dev',
                    ),
                ), 'branches' => Interval::noDev()),
                new MultiConstraint(array(
                    new MultiConstraint(array(
                        new Constraint('>=', '1.0.0.0-dev'),
                        new Constraint('<', '2.0.0.0-dev'),
                    ), true),
                    new MultiConstraint(array(
                        new Constraint('>=', '1.2.0.0-dev'),
                        new Constraint('<', '2.0.0.0-dev'),
                    ), true),
                    new MultiConstraint(array(
                        new Constraint('>=', '1.4.0.0-dev'),
                        new Constraint('<', '1.9.0.0-dev'),
                    ), true),
                    new MultiConstraint(array(
                        new Constraint('>=', '1.5.0.0-dev'),
                        new Constraint('<', '1.7.0.0-dev'),
                    ), true),
                    new MultiConstraint(array(
                        new Constraint('>=', '1.5.0.0-dev'),
                        new Constraint('<', '3.0.0.0-dev'),
                    ), true),
                ), true),
            ),
            'conjunctive constraints with disjunctive subcomponents should be intersected, not flattened by version parser' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 1.8.0.0-dev',
                        'end' => '< 1.10.0.0-dev',
                    ),
                    array(
                        'start' => '>= 1.12.0.0-dev',
                        'end' => '< 2.0.0.0-dev',
                    ),
                ), 'branches' => Interval::noDev()),
                new MultiConstraint(array(
                    new MultiConstraint(array( // 1.0 - 1.2 || ^1.5
                        new MultiConstraint(array(
                            new Constraint('>=', '1.0.0.0-dev'),
                            new Constraint('<', '1.3.0.0-dev'),
                        ), true),
                        new MultiConstraint(array(
                            new Constraint('>=', '1.5.0.0-dev'),
                            new Constraint('<', '2.0.0.0-dev'),
                        ), true),
                    ), false),
                    new MultiConstraint(array( // 1.8 - 1.9 || ^1.12
                        new MultiConstraint(array(
                            new Constraint('>=', '1.8.0.0-dev'),
                            new Constraint('<', '1.10.0.0-dev'),
                        ), true),
                        new MultiConstraint(array(
                            new Constraint('>=', '1.12.0.0-dev'),
                            new Constraint('<', '2.0.0.0-dev'),
                        ), true),
                    ), false),
                ), true),
            ),
            'conjunctive constraints with equal constraints' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 1.3.2.0-dev',
                        'end' => '<= 1.3.2.0-dev',
                    ),
                ), 'branches' => Interval::noDev()),
                new MultiConstraint(array(
                    new MultiConstraint(array(
                        new Constraint('==', '1.3.1.0-dev'),
                        new Constraint('==', '1.3.2.0-dev'),
                        new Constraint('==', '1.3.3.0-dev'),
                    ), false),
                    new Constraint('==', '1.3.2.0-dev'),
                ), true),
            ),
            'conjunctive constraints simple' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 1.5.0.0-dev',
                        'end' => '< 3.0.0.0-dev',
                    ),
                ), 'branches' => Interval::noDev()),
                '1.5 - 2'
            ),
            'conjunctive constraints with dev exclusions' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 1.0.0.0-dev',
                        'end' => '< 1.2.3.0',
                    ),
                    array(
                        'start' => '> 1.2.3.0',
                        'end' => '< 1.4.5.0',
                    ),
                    array(
                        'start' => '> 1.4.5.0',
                        'end' => '< 2.0.0.0-dev',
                    ),
                ), 'branches' => Interval::noDev()),
                '!= 1.4.5, ^1.0, != 1.2.3, != 2.3, != dev-foo, != dev-master'
            ),
            'conjunctive constraints with dev exact versions suppresses the number scope matches' => array(
                self::INTERVAL_NONE,
                '!= 1.4.5, ^1.0, != 1.2.3, != 2.3, == dev-foo, == dev-foo'
            ),
            'conjunctive constraints with dev exact versions suppresses the number scope matches, but keeps dev- match if number constraints allowed dev*' => array(
                array('numeric' => array(
                ), 'branches' => array('names' => array('dev-foo'), 'exclude' => false)),
                '!= 1.2.3, != 2.3, == dev-foo, == dev-foo'
            ),
            'disjunctive constraints with exclusions in dev constraints makes the number scope match *' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 0.0.0.0-dev',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => array('names' => array('dev-foo'), 'exclude' => true)),
                '^1.0 || != dev-foo'
            ),
            'disjunctive constraints with exclusions in dev constraints makes number scope match *' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 0.0.0.0-dev',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => array('names' => array('dev-foo'), 'exclude' => true)),
                '^1.0 || != dev-foo'
            ),
            'disjunctive constraints with exclusions, if matches * in number scope and dev scope, then * is returned' => array(
                self::INTERVAL_ANY,
                '!= 1.4.5 || ^1.0 || != dev-foo || != dev-master || == dev-master'
            ),
            'disjunctive constraints with exclusions, if dev constraints match *, then * is returned for everything' => array(
                self::INTERVAL_ANY,
                '^1.0 || != dev-master || == dev-master'
            ),
            'disjunctive constraints with exclusions, if dev constraints match * except in dev scope, then * is returned for number scope' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 0.0.0.0-dev',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => array('names' => array('dev-foo'), 'exclude' => true)),
                '^1.0 || != dev-foo || == dev-master'
            ),
            'disjunctive constraints with exact dev matches returns number scope as it should and unique dev constraints' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 1.0.0.0-dev',
                        'end' => '< 2.0.0.0-dev',
                    ),
                ), 'branches' => array('names' => array('dev-foo', 'dev-master'), 'exclude' => false)),
                '^1.0 || == dev-foo || == dev-master || == dev-master'
            ),
            'conjunctive constraints with exact versions' => array(
                self::INTERVAL_NONE,
                'dev-master, ^1.0'
            ),
            'conjunctive constraints with exact versions, dev only, diff version should result in no interval and no constraints' => array(
                self::INTERVAL_NONE,
                'dev-master, dev-foo'
            ),
            'conjunctive constraints with exact versions, dev only, same version should pass through' => array(
                array('numeric' => array(), 'branches' => array('names' => array('dev-master'), 'exclude' => false)),
                'dev-master, dev-master'
            ),
            'conjunctive constraints with same dev exclusion, should result in * with dev exclusion' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 0.0.0.0-dev',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => array('names' => array('dev-master'), 'exclude' => true)),
                '!= dev-master, != dev-master'
            ),
            'conjunctive constraints with different dev exclusion, should result in * with dev exclusions' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 0.0.0.0-dev',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => array('names' => array('dev-master', 'dev-foo'), 'exclude' => true)),
                '!= dev-master, != dev-foo'
            ),
            'disjunctive constraints with exact versions' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 1.0.0.0-dev',
                        'end' => '< 2.0.0.0-dev',
                    ),
                ), 'branches' => array('names' => array('dev-master', 'dev-foo'), 'exclude' => false)),
                'dev-master || ^1.0 || dev-foo || dev-master'
            ),
            'conjunctive constraints with * should skip it' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 1.0.0.0-dev',
                        'end' => '< 2.0.0.0-dev',
                    ),
                ), 'branches' => Interval::noDev()),
                '^1.0, *'
            ),
            'disjunctive constraints with * should result in *' => array(
                self::INTERVAL_ANY,
                '^1.0 || *'
            ),
            'conjunctive constraints with only * should result in *' => array(
                self::INTERVAL_ANY,
                '*, *'
            ),
            'conjunctive constraints equivalent of * should result in *' => array(
                self::INTERVAL_ANY_NODEV,
                new MultiConstraint(array(new Constraint('>=', '0.0.0.0-dev'), new Constraint('<', PHP_INT_MAX.'.0.0.0'))),
            ),
            'disjunctive constraints with * and dev exclusion should not return the dev exclusion' => array(
                self::INTERVAL_ANY,
                '!= dev-foo || *'
            ),
            'conjunctive constraints with various dev constraints/2' => array(
                array('numeric' => array(
                    array(
                        'start' => '> 5.0.0.0',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => Interval::noDev()),
                '> 5, *'
            ),
            'conjunctive constraints with various dev constraints/3' => array(
                array('numeric' => array(
                    array(
                        'start' => '> 5.0.0.0',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => Interval::noDev()),
                '!= dev-foo, > 5'
            ),
            'conjunctive constraints with various dev constraints/4' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 0.0.0.0-dev',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => array('names' => array('dev-foo'), 'exclude' => true)),
                '!= dev-foo, != dev-foo'
            ),
            'conjunctive constraints with various dev constraints/5' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 0.0.0.0-dev',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => array('names' => array('dev-foo', 'dev-bar'), 'exclude' => true)),
                '!= dev-foo, != dev-bar'
            ),
            'conjunctive constraints with various dev constraints/6' => array(
                array('numeric' => array(), 'branches' => array('names' => array('dev-bar'), 'exclude' => false)),
                '!= dev-foo, == dev-bar'
            ),
            'conjunctive constraints with various dev constraints/7' => array(
                self::INTERVAL_NONE,
                'dev-foo, > 5'
            ),
            'complex conjunctive which can not match anything' => array(
                self::INTERVAL_NONE,
                '!= 1.0, != 1.0, != dev-foo, 1.0.5.*, == dev-bla'
            ),
            'conjunctive with more than one dev negation' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 0.0.0.0-dev',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => array('names' => array('dev-master', 'dev-foo'), 'exclude' => true)),
                '!= dev-master, != dev-foo'
            ),
            'disjunctive constraints with various dev constraints' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 0.0.0.0-dev',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => array('names' => array('dev-foo'), 'exclude' => true)),
                '!= dev-foo, != dev-bar || != dev-foo'
            ),
            'disjunctive constraints with various dev constraints/2' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 0.0.0.0-dev',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => array('names' => array('dev-foo', 'dev-bar'), 'exclude' => true)),
                '!= dev-foo, != dev-bar || != dev-foo, != dev-bar'
            ),
            'disjunctive constraints with various dev constraints/3' => array(
                self::INTERVAL_ANY,
                new MultiConstraint(array(new Constraint('!=', 'dev-foo'), new Constraint('!=', 'dev-bar')), false),
            ),
            'disjunctive constraints with various dev constraints/4' => array(
                array('numeric' => array(),
                    'branches' => array('names' => array('dev-foo', 'dev-bar'), 'exclude' => false),
                ),
                '== dev-foo || == dev-bar'
            ),
            'disjunctive constraints with various dev constraints/5' => array(
                self::INTERVAL_ANY,
                '== dev-foo || != dev-foo'
            ),
            'disjunctive constraints with various dev constraints/6' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 0.0.0.0-dev',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => array('names' => array('dev-bar'), 'exclude' => true)),
                '== dev-foo || != dev-bar'
            ),
            'disjunctive constraints with various dev constraints/7' => array(
                array('numeric' => array(
                    array(
                        'start' => '>= 0.0.0.0-dev',
                        'end' => '< '.PHP_INT_MAX.'.0.0.0',
                    ),
                ), 'branches' => array('names' => array('dev-bar'), 'exclude' => true)),
                '== dev-foo || != dev-bar || != dev-bar'
            ),
            'disjunctive constraints with various dev constraints/8' => array(
                self::INTERVAL_ANY,
                '== dev-foo || != dev-bar || != dev-foo'
            ),
            'match-none constraints result in no interval' => array(
                self::INTERVAL_NONE,
                new MatchNoneConstraint
            ),
            'match-none constraint inside conjunctive multi results in no interval' => array(
                self::INTERVAL_NONE,
                new MultiConstraint(array(
                    new MultiConstraint(array(
                        new Constraint('==', '1.3.1.0-dev'),
                        new Constraint('==', '1.3.2.0-dev'),
                        new Constraint('==', '1.3.3.0-dev'),
                    ), false),
                    new MatchNoneConstraint,
                ), true),
            ),
        );
    }
}